From 2b856b9f1257c9347b5a523e265351b0fefad2ce Mon Sep 17 00:00:00 2001 From: iav-DaBi Date: Mon, 2 Dec 2024 21:49:22 +0100 Subject: [PATCH] Fix some issues --- .github/workflows/ci.yml | 2 +- src/UserInterface/DriverUI.py | 2 +- test/UnitTest/DataModel/Vehicle_Test.py | 14 +++++++------- .../EnvironmentManager_Test.py | 4 ++-- test/UnitTest/UserInterface/DriverUI_Test.py | 7 +++++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c14a1e3..616a5d64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: - uses: ./.github/actions/setup - name: Run fast tests itself with pytest run: | - pipenv run pytest -m 'not skip_ci and not slow' test + pipenv run pytest -m 'not skip_ci and not slow and not one_anki_car_needed' test pytest-testing-slow: name: Run slow tests with pytest diff --git a/src/UserInterface/DriverUI.py b/src/UserInterface/DriverUI.py index c2073ca3..f25e732a 100644 --- a/src/UserInterface/DriverUI.py +++ b/src/UserInterface/DriverUI.py @@ -19,7 +19,7 @@ from DataModel.Vehicle import Vehicle from EnvironmentManagement.EnvironmentManager import EnvironmentManager from EnvironmentManagement.ConfigurationHandler import ConfigurationHandler -from VehicleMovementManagement import BehaviourController +from VehicleMovementManagement.BehaviourController import BehaviourController logger = logging.getLogger(__name__) diff --git a/test/UnitTest/DataModel/Vehicle_Test.py b/test/UnitTest/DataModel/Vehicle_Test.py index 79374534..9ab8c59f 100644 --- a/test/UnitTest/DataModel/Vehicle_Test.py +++ b/test/UnitTest/DataModel/Vehicle_Test.py @@ -9,7 +9,6 @@ from DataModel.Vehicle import Vehicle from Items.Item import Item from LocationService.LocationService import LocationService -from VehicleManagement.VehicleController import VehicleController from VehicleManagement.FleetController import FleetController dummy_uuid = "FA:14:67:0F:39:FE" @@ -22,18 +21,19 @@ def init_vehicle(): @pytest.mark.one_anki_car_needed -def test_get_location(): - vctrl = VehicleController() +@pytest.mark.asyncio +async def test_get_location(): + loc_Service = LocationService(None) fleet_ctrl = FleetController() - found_vehicles = fleet_ctrl.scan_for_anki_cars() - mut = Vehicle(found_vehicles[0], vctrl) + found_vehicles = await fleet_ctrl.scan_for_anki_cars() + mut = Vehicle(found_vehicles[0], loc_Service) - mut.speed_request = 80.0 + mut.request_speed_percent(80.0) sleep(5) - mut.speed_request = 0.0 + mut.request_speed_percent(0.0) assert mut diff --git a/test/UnitTest/EnvironmentManagement/EnvironmentManager_Test.py b/test/UnitTest/EnvironmentManagement/EnvironmentManager_Test.py index 140366d3..9e3ea968 100644 --- a/test/UnitTest/EnvironmentManagement/EnvironmentManager_Test.py +++ b/test/UnitTest/EnvironmentManagement/EnvironmentManager_Test.py @@ -27,7 +27,7 @@ def get_mut_with_one_minute_playing_time(initialise_dependencies) -> Environment fleet_ctrl_mock, configuration_handler_mock = initialise_dependencies configuration_handler_mock.get_configuration.return_value = { "virtual_cars_pics": {"AB:CD:EF:12:34:56": "ABCDEF123456.svg", - "GH:IJ:KL:78:90:21": "GHIJKL789021.svg"}, + "GH:IJ:KL:78:90:21": "GHIJKL789021.svg"}, "driver": {"key1": "value1", "key2": "value2"}, "game_config": {"game_cfg_playing_time_limit_min": 1}} @@ -42,7 +42,7 @@ def get_mut_with_endless_playing_time(initialise_dependencies) -> EnvironmentMan configuration_handler_mock.get_configuration.return_value = { "virtual_cars_pics": {"AB:CD:EF:12:34:56": "ABCDEF123456.svg", - "GH:IJ:KL:78:90:21": "GHIJKL789021.svg"}, + "GH:IJ:KL:78:90:21": "GHIJKL789021.svg"}, "driver": {"key1": "value1", "key2": "value2"}, "game_config": {"game_cfg_playing_time_limit_min": 0}} diff --git a/test/UnitTest/UserInterface/DriverUI_Test.py b/test/UnitTest/UserInterface/DriverUI_Test.py index 3e2b4549..3df44c69 100644 --- a/test/UnitTest/UserInterface/DriverUI_Test.py +++ b/test/UnitTest/UserInterface/DriverUI_Test.py @@ -20,8 +20,11 @@ def initialise_dependencies(): Prepare a DriverUI, Environment Vehicle and Vehicle """ configuration_handler_mock = MagicMock(spec=ConfigurationHandler) - configuration_handler_mock.get_configuration.return_value = \ - {"game_config": {"game_cfg_playing_time_limit_min": 0}} + configuration_handler_mock.get_configuration.return_value = { + "virtual_cars_pics": {"AB:CD:EF:12:34:56": "ABCDEF123456.svg", + "GH:IJ:KL:78:90:21": "GHIJKL789021.svg"}, + "driver": {"key1": "value1", "key2": "value2"}, + "game_config": {"game_cfg_playing_time_limit_min": 0}} socket = AsyncServer(async_mode='asgi') fleet_ctrl = FleetController()