Skip to content

Commit

Permalink
Commit 185418a (open)
Browse files Browse the repository at this point in the history
by Claas, 2023-11-25 00:16

ship_traffic_generator.generate_traffic_situations() : Corrected an error I introduced with commit 185418a 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.
  • Loading branch information
ClaasRostock committed Nov 25, 2023
1 parent e0e7793 commit 7483674
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/trafficgen/ship_traffic_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions tests/test_trafficgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}

0 comments on commit 7483674

Please sign in to comment.