diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py index db8adad..20ffa36 100644 --- a/tests/fixtures/__init__.py +++ b/tests/fixtures/__init__.py @@ -122,16 +122,3 @@ def _make_euring2000plus_record_with_invalid_species(*, accuracy_of_coordinates: species_mentioned="12ABC", species_concluded="12ABC", ) - - -def _make_euring2020_record_for_coords(**kwargs) -> str: - return _make_euring2020_record(**kwargs) - - -def _make_euring2020_record_with_coords() -> str: - return _make_euring2020_record( - geographical_coordinates="." * 15, - accuracy_of_coordinates="A", - latitude="52.3760", - longitude="4.9000", - ) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0662f36..daa3798 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -5,9 +5,12 @@ import euring.main as main_module from euring import exceptions as euring_exceptions from euring.coordinates import _lat_to_euring_coordinate, _lng_to_euring_coordinate -from euring.fields import EURING_FIELDS +from euring.fields import EURING_KEY_INDEX from euring.main import app -from tests.fixtures import _make_euring2000plus_record_with_invalid_species, _make_euring2020_record_with_coords +from tests.fixtures import ( + _make_euring2000plus_record_with_invalid_species, + _make_euring2020_record, +) def test_lookup_place_verbose_includes_details(): @@ -59,7 +62,7 @@ def test_decode_cli_success(): def test_decode_cli_format_mismatch_fails(): runner = CliRunner() - record = _make_euring2020_record_with_coords() + record = _make_euring2020_record() result = runner.invoke(app, ["decode", "--format", "euring2000", record]) assert result.exit_code == 1 assert 'Format "EURING2000" conflicts with pipe-delimited data.' in result.output @@ -157,7 +160,7 @@ def test_validate_cli_invalid_format_hint(): def test_validate_cli_forced_euring2000_rejects_pipe_record(): import json - record = _make_euring2020_record_with_coords() + record = _make_euring2020_record() runner = CliRunner() result = runner.invoke(app, ["validate", "--json", "--format", "euring2000", record]) assert result.exit_code == 1 @@ -493,6 +496,12 @@ def test_convert_cli_downgrade_with_coords(): runner = CliRunner() lat = _lat_to_euring_coordinate(52.3760) lng = _lng_to_euring_coordinate(4.9000) + euring2020_record_with_coordinates = _make_euring2020_record( + geographical_coordinates="." * 15, + accuracy_of_coordinates="A", + latitude="52.3760", + longitude="4.9000", + ) result = runner.invoke( app, [ @@ -502,10 +511,12 @@ def test_convert_cli_downgrade_with_coords(): "--to", "euring2000plus", "--force", - _make_euring2020_record_with_coords(), + euring2020_record_with_coordinates, ], ) assert result.exit_code == 0 fields = result.output.strip().split("|") - geo_index = next(i for i, f in enumerate(EURING_FIELDS) if f["key"] == "geographical_coordinates") - assert fields[geo_index] == f"{lat}{lng}" + accuracy_of_coordinates = fields[EURING_KEY_INDEX["accuracy_of_coordinates"]] + assert accuracy_of_coordinates == "0" # Changed from 'A' to '0' + geographical_coordinates = fields[EURING_KEY_INDEX["geographical_coordinates"]] + assert geographical_coordinates == f"{lat}{lng}" # Generated from latitude and longitude diff --git a/tests/test_converters.py b/tests/test_converters.py index 797247a..b94dc2c 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -8,7 +8,7 @@ from euring.converters import convert_euring_record from euring.coordinates import _lat_to_euring_coordinate, _lng_to_euring_coordinate from euring.fields import EURING_FIELDS -from tests.fixtures import _make_euring2020_record_with_coords +from tests.fixtures import _make_euring2020_record def _load_fixture(module_name: str, attr: str) -> str: @@ -98,7 +98,12 @@ def test_convert_alpha_accuracy_invalid(): def test_convert_coordinate_downgrade_fills(): - record = _make_euring2020_record_with_coords() + record = _make_euring2020_record( + geographical_coordinates="." * 15, + accuracy_of_coordinates="A", + latitude="52.3760", + longitude="4.9000", + ) lat = _lat_to_euring_coordinate(52.3760) lng = _lng_to_euring_coordinate(4.9000) converted = convert_euring_record(record, target_format="euring2000plus", force=True) diff --git a/tests/test_decoding.py b/tests/test_decoding.py index 31aec6c..c626265 100644 --- a/tests/test_decoding.py +++ b/tests/test_decoding.py @@ -18,7 +18,7 @@ from tests.fixtures import ( _make_euring2000plus_record, _make_euring2000plus_record_with_invalid_species, - _make_euring2020_record_for_coords, + _make_euring2020_record, ) @@ -203,7 +203,7 @@ def test_decode_invalid_species_format(self): def test_decode_euring2020_rejects_geo_with_lat_long(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="+0000000+0000000", latitude="1.0000", longitude="2.0000", @@ -213,7 +213,7 @@ def test_decode_euring2020_rejects_geo_with_lat_long(self): def test_decode_euring2020_requires_longitude_with_latitude(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="...............", latitude="1.0000", longitude="", @@ -223,7 +223,7 @@ def test_decode_euring2020_requires_longitude_with_latitude(self): def test_decode_euring2020_requires_latitude_with_longitude(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="...............", latitude="", longitude="2.0000", @@ -233,7 +233,7 @@ def test_decode_euring2020_requires_latitude_with_longitude(self): def test_decode_euring2020_latitude_out_of_range(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="...............", latitude="90.0001", longitude="2.0000", @@ -243,7 +243,7 @@ def test_decode_euring2020_latitude_out_of_range(self): def test_decode_euring2020_longitude_out_of_range(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="...............", latitude="10.0000", longitude="180.0001", @@ -253,7 +253,7 @@ def test_decode_euring2020_longitude_out_of_range(self): def test_decode_euring2020_latitude_too_many_decimals(self): record = EuringRecord.decode( - _make_euring2020_record_for_coords( + _make_euring2020_record( geographical_coordinates="...............", latitude="10.00001", longitude="2.0000",