From e8934f14999f8c3985626dfb70b036f619af6fa5 Mon Sep 17 00:00:00 2001 From: Conengmo <33519926+Conengmo@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:14:10 +0100 Subject: [PATCH] apply ruff and mypy on test_aoe --- tests/test_aoe.py | 51 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/tests/test_aoe.py b/tests/test_aoe.py index 4df0baf..7897f99 100644 --- a/tests/test_aoe.py +++ b/tests/test_aoe.py @@ -10,10 +10,12 @@ def mock_scene(): return Mock() + @pytest.fixture def aoe_manager(mock_scene): return AreaOfEffectManager(mock_scene) + def test_area_of_effect_manager_wait_for(aoe_manager): callback = Mock() aoe_manager.wait_for("circle", "red", callback) @@ -21,35 +23,74 @@ def test_area_of_effect_manager_wait_for(aoe_manager): assert aoe_manager.waiting_for.keywords == {"color": "red"} assert aoe_manager.callback == callback + def test_area_of_effect_manager_cancel(aoe_manager): aoe_manager.wait_for("circle", "red", Mock()) aoe_manager.cancel() assert aoe_manager.waiting_for is None assert aoe_manager.callback is None + def test_area_of_effect_manager_clear_all(aoe_manager): aoe_manager._store = [Mock(), Mock()] aoe_manager.clear_all() assert aoe_manager._store == [] + def test_area_of_effect_manager_mouse_press_event(aoe_manager): aoe_manager.wait_for("circle", "red", Mock()) - event = QMouseEvent(QMouseEvent.Type.MouseButtonPress, QPointF(10, 20), Qt.LeftButton, Qt.NoButton, Qt.NoModifier) + event = QMouseEvent( + QMouseEvent.Type.MouseButtonPress, + QPointF(10, 20), + Qt.LeftButton, # type: ignore[attr-defined] + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoModifier, # type: ignore[attr-defined] + ) assert aoe_manager.mouse_press_event(event) is True assert aoe_manager.waiting_for.keywords == {"color": "red", "x1": 10, "y1": 20} + def test_area_of_effect_manager_mouse_move_event(aoe_manager, mock_scene): aoe_manager.wait_for("circle", "red", Mock()) - aoe_manager.mouse_press_event(QMouseEvent(QMouseEvent.Type.MouseButtonPress, QPointF(10, 20), Qt.LeftButton, Qt.NoButton, Qt.NoModifier)) - event = QMouseEvent(QMouseEvent.Type.MouseMove, QPointF(30, 40), Qt.NoButton, Qt.NoButton, Qt.NoModifier) + aoe_manager.mouse_press_event( + QMouseEvent( + QMouseEvent.Type.MouseButtonPress, + QPointF(10, 20), + Qt.LeftButton, # type: ignore[attr-defined] + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoModifier, # type: ignore[attr-defined] + ) + ) + event = QMouseEvent( + QMouseEvent.Type.MouseMove, + QPointF(30, 40), + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoModifier, # type: ignore[attr-defined] + ) aoe_manager.mouse_move_event(event) assert mock_scene.addItem.call_count == 1 + def test_area_of_effect_manager_mouse_release_event(aoe_manager, mock_scene): callback = Mock() aoe_manager.wait_for("circle", "red", callback) - aoe_manager.mouse_press_event(QMouseEvent(QMouseEvent.Type.MouseButtonPress, QPointF(10, 20), Qt.LeftButton, Qt.NoButton, Qt.NoModifier)) - event = QMouseEvent(QMouseEvent.Type.MouseButtonRelease, QPointF(30, 40), Qt.LeftButton, Qt.NoButton, Qt.NoModifier) + aoe_manager.mouse_press_event( + QMouseEvent( + QMouseEvent.Type.MouseButtonPress, + QPointF(10, 20), + Qt.LeftButton, # type: ignore[attr-defined] + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoModifier, # type: ignore[attr-defined] + ) + ) + event = QMouseEvent( + QMouseEvent.Type.MouseButtonRelease, + QPointF(30, 40), + Qt.LeftButton, # type: ignore[attr-defined] + Qt.NoButton, # type: ignore[attr-defined] + Qt.NoModifier, # type: ignore[attr-defined] + ) assert aoe_manager.mouse_release_event(event) is True assert callback.call_count == 1 assert mock_scene.addItem.call_count == 1