From 857512a17d0d792c7cc5e9d63a229deced043b6a Mon Sep 17 00:00:00 2001 From: xZetsubou Date: Fri, 31 Jan 2025 06:57:50 +0300 Subject: [PATCH] ci(tests): update pyproject --- .github/workflows/ci.yml | 2 +- pyproject.toml | 5 +++++ tests/__init__.py | 4 ---- tests/test_alarm_control_panel.py | 1 - tests/test_auto_configure.py | 1 - tests/test_binary_sensor.py | 1 - tests/test_button.py | 1 - tests/test_climate.py | 1 - tests/test_cover.py | 1 - tests/test_discovery.py | 1 - tests/test_fan.py | 1 - tests/test_humidifier.py | 1 - tests/test_light.py | 1 - tests/test_lock.py | 1 - tests/test_number.py | 1 - tests/test_remote.py | 1 - tests/test_select.py | 1 - tests/test_siren.py | 1 - tests/test_switch.py | 2 +- tests/test_vacuum.py | 1 - tests/test_water_heater.py | 1 - 21 files changed, 7 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0fca1b6c..c19f0c1e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,4 +95,4 @@ jobs: - name: "Pytest" run: | - ${{needs.base.outputs.PY_PATH}}/bin/pytest --cov tests/ --disable-warnings -s + ${{needs.base.outputs.PY_PATH}}/bin/pytest --cov --disable-warnings -s diff --git a/pyproject.toml b/pyproject.toml index 16c0d8232..080251257 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,11 @@ quiet-level = 3 [tool.pytest.ini_options] asyncio_default_fixture_loop_scope = "function" +testpaths = ["tests"] +asyncio_mode = "auto" + +[tool.coverage.run] +source = ["tests"] # pylint config stolen from Home Assistant [tool.pylint.MAIN] diff --git a/tests/__init__.py b/tests/__init__.py index 689534429..d0aaa1083 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -10,16 +10,12 @@ from typing import Any from unittest.mock import AsyncMock, Mock from homeassistant.config_entries import ConfigEntry -from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant from custom_components.localtuya import TuyaCloudApi from custom_components.localtuya import coordinator from custom_components.localtuya import entity from custom_components.localtuya.const import DOMAIN -custom_comp_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -sys.path.append(custom_comp_path) - HOST = "192.168.1.100" DEVICE_NAME = "device" diff --git a/tests/test_alarm_control_panel.py b/tests/test_alarm_control_panel.py index 185f9789d..68e89343d 100644 --- a/tests/test_alarm_control_panel.py +++ b/tests/test_alarm_control_panel.py @@ -45,7 +45,6 @@ DPS_STATUS = {"1": None} -@pytest.mark.asyncio async def test_alarm_control_panel(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaAlarmControlPanel) entities: list[LocalTuyaAlarmControlPanel] = get_entites(device) diff --git a/tests/test_auto_configure.py b/tests/test_auto_configure.py index 555a28247..b5fbd4328 100644 --- a/tests/test_auto_configure.py +++ b/tests/test_auto_configure.py @@ -205,7 +205,6 @@ } -@pytest.mark.asyncio async def test_auto_configure(): for k in PLATFORMS.values(): diff --git a/tests/test_binary_sensor.py b/tests/test_binary_sensor.py index 126e35e5b..791d061a7 100644 --- a/tests/test_binary_sensor.py +++ b/tests/test_binary_sensor.py @@ -27,7 +27,6 @@ DPS_STATUS = {"1": "activated", "2": False} -@pytest.mark.asyncio async def test_button(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaBinarySensor) entities: list[LocalTuyaBinarySensor] = get_entites(device) diff --git a/tests/test_button.py b/tests/test_button.py index f4bb10e8a..f64a09ab7 100644 --- a/tests/test_button.py +++ b/tests/test_button.py @@ -26,7 +26,6 @@ DPS_STATUS = {"1": True, "2": False} -@pytest.mark.asyncio async def test_button(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaButton) entities: list[LocalTuyaButton] = get_entites(device) diff --git a/tests/test_climate.py b/tests/test_climate.py index 6fb084cc0..a48e88bc0 100644 --- a/tests/test_climate.py +++ b/tests/test_climate.py @@ -62,7 +62,6 @@ } -@pytest.mark.asyncio async def test_climate(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaClimate) entities: list[LocalTuyaClimate] = get_entites(device) diff --git a/tests/test_cover.py b/tests/test_cover.py index 6e52f3e76..9b21a2625 100644 --- a/tests/test_cover.py +++ b/tests/test_cover.py @@ -36,7 +36,6 @@ DPS_STATUS = {"1": "stop", "2": 80, "3": 80} -@pytest.mark.asyncio async def test_cover(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaCover) entities: list[LocalTuyaCover] = get_entites(device) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 81af55cca..74cb0e989 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -9,7 +9,6 @@ DEVICE3_5 = b"\x00\x00f\x99\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\xf0\x93\x07 \xd5\x92~\xcf\xf2\x91\x85S\xdc\x9f\x8dY=dS\x18\xca>\xae\xc2\xcf\xe7iV\xf2{\xc4!\xe7\xb8\x00i\x11K\x11j\x0e5\xed\x8c\xe7mO\x91c\xceAGS\x7f@\xd6\x12\n\xce\x92\xb4\x9a\xe5\xef\xf4\x8e\xdf\xd3\xe1\xda\rt\xf1\xee\x1b\x86z\xb28\x9a\x11\xebx\x9c\xe4\x9b\x19t6L\x13JZ7\xe7\xa6\x88\xb9\xa9\xcc\xf91\xdc\x8f\x1d%>\x13\x10M'\xeeG\x9e\xf7\xe5\xd6\xdeK1W\xe0\xa9\xf5\x8c\\\xa1\xd6<\x1e\x1ec\xfb\xc9 CV\x9d\xa3C@I\x1c\x15\xb4=6\xa0\xce\n+\xef\x1c\xc1\x96\xf1_\xc0Y2\xe2\xcd\xc4j\xa7H\xcf\xe1B\xe1\xed^\x98\xfe;\xf1P:!%\x82*\xc9\xf6\xbd\x17\x8e\xd9\xb5\xdf\xba\x19\x8d\x03\x9b\xfa\x00\x99s\xd6t\x0eD=&\xd8\xd1\xd7\x827\xec\xac\xf2\x19\x8a\xfe\x94\x1f\xd5\xe6\xe1a\xc1\xfb 1\xa8\xf4]vd\x18\xed\x86<\x11\x13\xde\x14\xf2\xba\x00\x00\x99f" -@pytest.mark.asyncio async def test_dsicovery(): mock_callback = AsyncMock() discovery = TuyaDiscovery(mock_callback) diff --git a/tests/test_fan.py b/tests/test_fan.py index ac6d0d3ed..59407c8de 100644 --- a/tests/test_fan.py +++ b/tests/test_fan.py @@ -51,7 +51,6 @@ DPS_STATUS = {"1": True, "2": "mid", "3": 4, "4": "reverse", "6": True} -@pytest.mark.asyncio async def test_fan(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaFan) entities: list[LocalTuyaFan] = get_entites(device) diff --git a/tests/test_humidifier.py b/tests/test_humidifier.py index 22a7e1f68..4b57876c2 100644 --- a/tests/test_humidifier.py +++ b/tests/test_humidifier.py @@ -35,7 +35,6 @@ DPS_STATUS = {"1": True, "2": 34, "4": "drying", "16": 34} -@pytest.mark.asyncio async def test_humidifier(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaHumidifier) entities: list[LocalTuyaHumidifier] = get_entites(device) diff --git a/tests/test_light.py b/tests/test_light.py index ee30f5602..67b8947aa 100644 --- a/tests/test_light.py +++ b/tests/test_light.py @@ -45,7 +45,6 @@ BLE_COLOR = "0319090087db1c" -@pytest.mark.asyncio async def test_light(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaLight) entities: list[LocalTuyaLight] = get_entites(device) diff --git a/tests/test_lock.py b/tests/test_lock.py index fb378cd1c..4d1bc0acd 100644 --- a/tests/test_lock.py +++ b/tests/test_lock.py @@ -25,7 +25,6 @@ DPS_STATUS = {"1": None, "2": "unlocked"} -@pytest.mark.asyncio async def test_lock(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaLock) entities: list[LocalTuyaLock] = get_entites(device) diff --git a/tests/test_number.py b/tests/test_number.py index c7e509b83..38dcf35d7 100644 --- a/tests/test_number.py +++ b/tests/test_number.py @@ -26,7 +26,6 @@ DPS_STATUS = {"1": 500} -@pytest.mark.asyncio async def test_lock(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaNumber) entities: list[LocalTuyaNumber] = get_entites(device) diff --git a/tests/test_remote.py b/tests/test_remote.py index 3879eedc4..a6365af47 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -29,7 +29,6 @@ } -@pytest.mark.asyncio async def test_lock(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaRemote) entities: list[LocalTuyaRemote] = get_entites(device) diff --git a/tests/test_select.py b/tests/test_select.py index fc8ab977b..945da3af4 100644 --- a/tests/test_select.py +++ b/tests/test_select.py @@ -27,7 +27,6 @@ DPS_STATUS = {"5": "back"} -@pytest.mark.asyncio async def test_lock(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaSelect) entities: list[LocalTuyaSelect] = get_entites(device) diff --git a/tests/test_siren.py b/tests/test_siren.py index 70ccb405d..dd2b8cfa1 100644 --- a/tests/test_siren.py +++ b/tests/test_siren.py @@ -26,7 +26,6 @@ DPS_STATUS = {"5": STATE_ON} -@pytest.mark.asyncio async def test_siren(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaSiren) entities: list[LocalTuyaSiren] = get_entites(device) diff --git a/tests/test_switch.py b/tests/test_switch.py index 213f4344a..d9e36379f 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1,6 +1,7 @@ """Test for localtuya.""" from . import * +from homeassistant.const import EntityCategory from custom_components.localtuya.switch import LocalTuyaSwitch, DOMAIN as SWITCH_DOMAIN CONFIG = { @@ -32,7 +33,6 @@ DPS_STATUS = {"1": True, "2": False} -@pytest.mark.asyncio async def test_switch(): device = await init(CONFIG, SWITCH_DOMAIN, LocalTuyaSwitch) entities: list[LocalTuyaSwitch] = get_entites(device) diff --git a/tests/test_vacuum.py b/tests/test_vacuum.py index 2e8c2e5c9..ed077ab91 100644 --- a/tests/test_vacuum.py +++ b/tests/test_vacuum.py @@ -57,7 +57,6 @@ } -@pytest.mark.asyncio async def test_vacuum(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaVacuum) entities: list[LocalTuyaVacuum] = get_entites(device) diff --git a/tests/test_water_heater.py b/tests/test_water_heater.py index 3772bb0f1..f868608f5 100644 --- a/tests/test_water_heater.py +++ b/tests/test_water_heater.py @@ -48,7 +48,6 @@ } -@pytest.mark.asyncio async def test_water_heater(): device = await init(CONFIG, PLATFORM_DOMAIN, LocalTuyaWaterHeater) entities: list[LocalTuyaWaterHeater] = get_entites(device)