From 7483674332f2078d74f8223087f7fcbcf1ceb49c Mon Sep 17 00:00:00 2001 From: Claas Date: Sat, 25 Nov 2023 16:47:04 +0100 Subject: [PATCH] Commit 185418af (open) by Claas, 2023-11-25 00:16 ship_traffic_generator.generate_traffic_situations() : Corrected an error I introduced with commit 185418af on 2023-11-25 00:16 lat_lon_0 of the new traffic_situation needs to be set to lat_lon_0 from the encounter settings. It was, though, set to lat_lon_0 from the desired traffic situation (which is usually None). I introduced the error when changing the code to use the new pdantic data types. Now corrected. Also added a related assertion to the tests to ensure the error does not get introduced again. --- src/trafficgen/ship_traffic_generator.py | 2 +- tests/test_trafficgen.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/trafficgen/ship_traffic_generator.py b/src/trafficgen/ship_traffic_generator.py index 53d0e80..3c5cdc5 100644 --- a/src/trafficgen/ship_traffic_generator.py +++ b/src/trafficgen/ship_traffic_generator.py @@ -54,7 +54,7 @@ def generate_traffic_situations( title=desired_traffic_situation.title, input_file_name=desired_traffic_situation.input_file_name, common_vector=desired_traffic_situation.common_vector, - lat_lon_0=desired_traffic_situation.lat_lon_0, + lat_lon_0=encounter_settings.lat_lon_0, ) assert traffic_situation.common_vector is not None own_ship.start_pose = desired_traffic_situation.own_ship.start_pose diff --git a/tests/test_trafficgen.py b/tests/test_trafficgen.py index a043701..e9269a1 100644 --- a/tests/test_trafficgen.py +++ b/tests/test_trafficgen.py @@ -34,9 +34,7 @@ def test_basic_cli(): assert "Usage:" in result.output help_result = runner.invoke(cli.main, ["--help"]) assert help_result.exit_code == 0 - assert ( - "--help" in help_result.output and "Show this message and exit" in help_result.output - ) # noqa: E501 + assert "--help" in help_result.output and "Show this message and exit" in help_result.output # noqa: E501 def test_gen_situations_cli( @@ -124,6 +122,7 @@ def test_gen_situations_1_ts_full_spec_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) == 1 @@ -166,6 +165,7 @@ def test_gen_situations_1_ts_partly_spec_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None # @TODO: @TomArne: As again the tests on GitHub failed here, # I have for now adapted the assertion to not test for @@ -215,6 +215,7 @@ def test_gen_situations_1_ts_minimum_spec_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) == 1 @@ -256,6 +257,7 @@ def test_gen_situations_2_ts_one_to_many_situations_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) == 2 @@ -297,6 +299,7 @@ def test_gen_situations_one_to_many_situations_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) in {1, 2, 3} @@ -339,6 +342,7 @@ def test_gen_situations_ot_gw_target_ship_speed_too_high_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) == 0 @@ -381,5 +385,6 @@ def test_gen_situations_baseline_cli( # sourcery skip: no-loop-in-tests for situation in situations: + assert situation.lat_lon_0 is not None assert situation.target_ship is not None assert len(situation.target_ship) in {1, 2, 3}