Skip to content

Commit

Permalink
Auto mark tests with looptime (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey authored Oct 29, 2024
1 parent 9e37763 commit 315c06f
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 29 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,10 @@ def cluster_handler_factory(
return ch

return cluster_handler_factory


def pytest_collection_modifyitems(config, items):
"""Add the looptime marker to all tests except the test_async.py file."""
for item in items:
if "test_async_.py" not in item.nodeid:
item.add_marker(pytest.mark.looptime)
1 change: 0 additions & 1 deletion tests/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ async def test_climate_hvac_action_running_state(
assert len(subscriber.mock_calls) == 2 * 6


@pytest.mark.looptime
async def test_sinope_time(
zha_gateway: Gateway,
):
Expand Down
8 changes: 0 additions & 8 deletions tests/test_debouncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
_LOGGER = logging.getLogger(__name__)


@pytest.mark.looptime
async def test_immediate_works(zha_gateway: Gateway) -> None:
"""Test immediate works."""
calls: list[None] = []
Expand Down Expand Up @@ -67,7 +66,6 @@ async def test_immediate_works(zha_gateway: Gateway) -> None:
assert debouncer._job.target == debouncer.function


@pytest.mark.looptime
async def test_immediate_works_with_schedule_call(zha_gateway: Gateway) -> None:
"""Test immediate works with scheduled calls."""
calls: list[None] = []
Expand Down Expand Up @@ -168,7 +166,6 @@ async def test_immediate_works_with_executor_function(zha_gateway: Gateway) -> N
debouncer.async_cancel()


@pytest.mark.looptime
async def test_immediate_works_with_passed_callback_function_raises(
zha_gateway: Gateway,
) -> None:
Expand Down Expand Up @@ -232,7 +229,6 @@ def _append_and_raise() -> None:
assert debouncer._job.target == debouncer.function


@pytest.mark.looptime
async def test_immediate_works_with_passed_coroutine_raises(
zha_gateway: Gateway,
) -> None:
Expand Down Expand Up @@ -296,7 +292,6 @@ async def _append_and_raise() -> None:
assert debouncer._job.target == debouncer.function


@pytest.mark.looptime
async def test_not_immediate_works(zha_gateway: Gateway) -> None:
"""Test immediate works."""
calls: list[None] = []
Expand Down Expand Up @@ -348,7 +343,6 @@ async def test_not_immediate_works(zha_gateway: Gateway) -> None:
assert debouncer._job.target == debouncer.function


@pytest.mark.looptime
async def test_not_immediate_works_schedule_call(zha_gateway: Gateway) -> None:
"""Test immediate works with schedule call."""
calls: list[None] = []
Expand Down Expand Up @@ -404,7 +398,6 @@ async def test_not_immediate_works_schedule_call(zha_gateway: Gateway) -> None:
assert debouncer._job.target == debouncer.function


@pytest.mark.looptime
async def test_immediate_works_with_function_swapped(zha_gateway: Gateway) -> None:
"""Test immediate works and we can change out the function."""
calls: list[None] = []
Expand Down Expand Up @@ -501,7 +494,6 @@ async def _func() -> None:
assert debouncer._timer_task is None


@pytest.mark.looptime
async def test_background(zha_gateway: Gateway) -> None:
"""Test background tasks are created when background is True."""
calls: list[None] = []
Expand Down
3 changes: 0 additions & 3 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async def _send_time_changed(zha_gateway: Gateway, seconds: int):
"zha.zigbee.cluster_handlers.general.BasicClusterHandler.async_initialize",
new=mock.AsyncMock(),
)
@pytest.mark.looptime
async def test_check_available_success(
zha_gateway: Gateway,
caplog: pytest.LogCaptureFixture,
Expand Down Expand Up @@ -200,7 +199,6 @@ def _update_last_seen(*args, **kwargs): # pylint: disable=unused-argument
"zha.zigbee.cluster_handlers.general.BasicClusterHandler.async_initialize",
new=mock.AsyncMock(),
)
@pytest.mark.looptime
async def test_check_available_unsuccessful(
zha_gateway: Gateway,
) -> None:
Expand Down Expand Up @@ -272,7 +270,6 @@ async def test_check_available_unsuccessful(
"zha.zigbee.cluster_handlers.general.BasicClusterHandler.async_initialize",
new=mock.AsyncMock(),
)
@pytest.mark.looptime
async def test_check_available_no_basic_cluster_handler(
zha_gateway: Gateway,
caplog: pytest.LogCaptureFixture,
Expand Down
2 changes: 0 additions & 2 deletions tests/test_device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
from unittest.mock import AsyncMock

import pytest
import zigpy.profiles.zha
from zigpy.zcl.clusters import general

Expand All @@ -24,7 +23,6 @@
from zha.application.registries import SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE


@pytest.mark.looptime
async def test_device_tracker(
zha_gateway: Gateway,
) -> None:
Expand Down
1 change: 0 additions & 1 deletion tests/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ async def async_set_preset_mode(
"zigpy.zcl.clusters.hvac.Fan.write_attributes",
new=AsyncMock(return_value=zcl_f.WriteAttributesResponse.deserialize(b"\x00")[0]),
)
@pytest.mark.looptime
async def test_zha_group_fan_entity(
zha_gateway: Gateway,
):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ async def test_gateway_initialize_bellows_thread(


@pytest.mark.parametrize("radio_concurrency", [1, 2, 8])
@pytest.mark.looptime
async def test_startup_concurrency_limit(
radio_concurrency: int,
zigpy_app_controller: ControllerApplication,
Expand Down Expand Up @@ -694,7 +693,6 @@ def test_gateway_connection_lost(zha_gateway: Gateway) -> None:
)


@pytest.mark.looptime
async def test_pollers_skip(
zha_gateway: Gateway,
caplog: pytest.LogCaptureFixture,
Expand Down
5 changes: 0 additions & 5 deletions tests/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ async def eWeLink_light_mock(
return zha_device


@pytest.mark.looptime
async def test_light_refresh(
zha_gateway: Gateway,
):
Expand Down Expand Up @@ -360,7 +359,6 @@ async def test_light_refresh(
"device, reporting",
[(LIGHT_ON_OFF, (1, 0, 0)), (LIGHT_LEVEL, (1, 1, 0)), (LIGHT_COLOR, (1, 1, 3))],
)
@pytest.mark.looptime
async def test_light(
zha_gateway: Gateway,
device: dict,
Expand Down Expand Up @@ -594,7 +592,6 @@ async def _async_shift_time(zha_gateway: Gateway):
await zha_gateway.async_block_till_done()


@pytest.mark.looptime
async def async_test_level_on_off_from_client(
zha_gateway: Gateway,
on_off_cluster: general.OnOff,
Expand Down Expand Up @@ -746,7 +743,6 @@ async def async_test_flash_from_client(
"zigpy.zcl.clusters.general.OnOff.request",
new=AsyncMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@pytest.mark.looptime
async def test_zha_group_light_entity(
zha_gateway: Gateway,
) -> None:
Expand Down Expand Up @@ -1890,7 +1886,6 @@ async def test_on_with_off_color(zha_gateway: Gateway) -> None:
"zigpy.zcl.clusters.general.LevelControl.request",
new=AsyncMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@pytest.mark.looptime
async def test_group_member_assume_state(zha_gateway: Gateway) -> None:
"""Test the group members assume state function."""

Expand Down
4 changes: 0 additions & 4 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ def assert_state(entity: PlatformEntity, state: Any, unit_of_measurement: str) -
assert entity.info_object.unit == unit_of_measurement


@pytest.mark.looptime
async def test_electrical_measurement_init(
zha_gateway: Gateway,
caplog: pytest.LogCaptureFixture,
Expand Down Expand Up @@ -1026,7 +1025,6 @@ async def test_elec_measurement_sensor_type(
assert entity.state["measurement_type"] == expected_type


@pytest.mark.looptime
async def test_elec_measurement_sensor_polling(zha_gateway: Gateway) -> None:
"""Test ZHA electrical measurement sensor polling."""

Expand Down Expand Up @@ -1276,7 +1274,6 @@ async def test_last_feeding_size_sensor_v2(zha_gateway: Gateway) -> None:
assert_state(entity, 5.0, "g")


@pytest.mark.looptime
async def test_device_counter_sensors(zha_gateway: Gateway) -> None:
"""Test coordinator counter sensor."""

Expand Down Expand Up @@ -1317,7 +1314,6 @@ async def test_device_counter_sensors(zha_gateway: Gateway) -> None:
assert len(zha_gateway.global_updater._update_listeners) == 3


@pytest.mark.looptime
async def test_device_unavailable_or_disabled_skips_entity_polling(
zha_gateway: Gateway,
caplog: pytest.LogCaptureFixture,
Expand Down
2 changes: 0 additions & 2 deletions tests/test_siren.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
from unittest.mock import patch

import pytest
from zigpy.const import SIG_EP_PROFILE
from zigpy.profiles import zha
from zigpy.zcl.clusters import general, security
Expand Down Expand Up @@ -120,7 +119,6 @@ async def test_siren(zha_gateway: Gateway) -> None:
assert entity.state["state"] is True


@pytest.mark.looptime
async def test_siren_timed_off(zha_gateway: Gateway) -> None:
"""Test zha siren platform."""
zha_device, cluster = await siren_mock(zha_gateway)
Expand Down
1 change: 0 additions & 1 deletion tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ async def test_switch(zha_gateway: Gateway) -> None:
assert bool(entity.state["state"]) is True


@pytest.mark.looptime
async def test_zha_group_switch_entity(zha_gateway: Gateway) -> None:
"""Test the switch entity for a ZHA group."""
device_switch_1 = await device_switch_1_mock(zha_gateway)
Expand Down

0 comments on commit 315c06f

Please sign in to comment.