diff --git a/tests/files/README.md b/tests/files/README.md index feb6652..f4ecea3 100644 --- a/tests/files/README.md +++ b/tests/files/README.md @@ -1,10 +1,12 @@ # Test fixture files +Organized into `fit/`, `gpx/`, and `tcx/` subdirectories by format. + ## Vendored FIT files `garmin-edge-820-bike.fit` and `garmin-fenix-5-bike.fit` are copied from the [python-fitparse](https://github.com/dtcooper/python-fitparse) test suite (`tests/files/`, commit `d88bb699`), which is distributed under the MIT license. -## Hand-written XML files +## Hand-written GPX & TCX files -Minimal fixtures written for this test suite, with round-number values chosen so tests can assert exact parsed output. +Minimal XML fixtures written for this test suite, with round-number values chosen so tests can assert exact parsed output. Each fixture documents its quirk in an XML comment, and the tests that reference it state the behavior it exercises. diff --git a/tests/files/garmin-edge-820-bike.fit b/tests/files/fit/garmin-edge-820-bike.fit similarity index 100% rename from tests/files/garmin-edge-820-bike.fit rename to tests/files/fit/garmin-edge-820-bike.fit diff --git a/tests/files/garmin-fenix-5-bike.fit b/tests/files/fit/garmin-fenix-5-bike.fit similarity index 100% rename from tests/files/garmin-fenix-5-bike.fit rename to tests/files/fit/garmin-fenix-5-bike.fit diff --git a/tests/files/bad_speed.gpx b/tests/files/gpx/bad_speed.gpx similarity index 100% rename from tests/files/bad_speed.gpx rename to tests/files/gpx/bad_speed.gpx diff --git a/tests/files/gpx10.gpx b/tests/files/gpx/gpx10.gpx similarity index 100% rename from tests/files/gpx10.gpx rename to tests/files/gpx/gpx10.gpx diff --git a/tests/files/gpxdata.gpx b/tests/files/gpx/gpxdata.gpx similarity index 100% rename from tests/files/gpxdata.gpx rename to tests/files/gpx/gpxdata.gpx diff --git a/tests/files/gpxtpx_v1.gpx b/tests/files/gpx/gpxtpx_v1.gpx similarity index 100% rename from tests/files/gpxtpx_v1.gpx rename to tests/files/gpx/gpxtpx_v1.gpx diff --git a/tests/files/mixed_offset.gpx b/tests/files/gpx/mixed_offset.gpx similarity index 100% rename from tests/files/mixed_offset.gpx rename to tests/files/gpx/mixed_offset.gpx diff --git a/tests/files/multi_segment.gpx b/tests/files/gpx/multi_segment.gpx similarity index 100% rename from tests/files/multi_segment.gpx rename to tests/files/gpx/multi_segment.gpx diff --git a/tests/files/no_time.gpx b/tests/files/gpx/no_time.gpx similarity index 100% rename from tests/files/no_time.gpx rename to tests/files/gpx/no_time.gpx diff --git a/tests/files/sample.gpx b/tests/files/gpx/sample.gpx similarity index 100% rename from tests/files/sample.gpx rename to tests/files/gpx/sample.gpx diff --git a/tests/files/unknown_extension.gpx b/tests/files/gpx/unknown_extension.gpx similarity index 100% rename from tests/files/unknown_extension.gpx rename to tests/files/gpx/unknown_extension.gpx diff --git a/tests/files/cadence_collision.tcx b/tests/files/tcx/cadence_collision.tcx similarity index 100% rename from tests/files/cadence_collision.tcx rename to tests/files/tcx/cadence_collision.tcx diff --git a/tests/files/duplicate_cadence.tcx b/tests/files/tcx/duplicate_cadence.tcx similarity index 100% rename from tests/files/duplicate_cadence.tcx rename to tests/files/tcx/duplicate_cadence.tcx diff --git a/tests/files/extra_vendor_type_attribute.tcx b/tests/files/tcx/extra_vendor_type_attribute.tcx similarity index 100% rename from tests/files/extra_vendor_type_attribute.tcx rename to tests/files/tcx/extra_vendor_type_attribute.tcx diff --git a/tests/files/laps_only.tcx b/tests/files/tcx/laps_only.tcx similarity index 100% rename from tests/files/laps_only.tcx rename to tests/files/tcx/laps_only.tcx diff --git a/tests/files/lx_namespace_reset.tcx b/tests/files/tcx/lx_namespace_reset.tcx similarity index 100% rename from tests/files/lx_namespace_reset.tcx rename to tests/files/tcx/lx_namespace_reset.tcx diff --git a/tests/files/mixed_content.tcx b/tests/files/tcx/mixed_content.tcx similarity index 100% rename from tests/files/mixed_content.tcx rename to tests/files/tcx/mixed_content.tcx diff --git a/tests/files/mixed_offset.tcx b/tests/files/tcx/mixed_offset.tcx similarity index 100% rename from tests/files/mixed_offset.tcx rename to tests/files/tcx/mixed_offset.tcx diff --git a/tests/files/no_position.tcx b/tests/files/tcx/no_position.tcx similarity index 100% rename from tests/files/no_position.tcx rename to tests/files/tcx/no_position.tcx diff --git a/tests/files/no_time.tcx b/tests/files/tcx/no_time.tcx similarity index 100% rename from tests/files/no_time.tcx rename to tests/files/tcx/no_time.tcx diff --git a/tests/files/running.tcx b/tests/files/tcx/running.tcx similarity index 100% rename from tests/files/running.tcx rename to tests/files/tcx/running.tcx diff --git a/tests/files/sample.tcx b/tests/files/tcx/sample.tcx similarity index 100% rename from tests/files/sample.tcx rename to tests/files/tcx/sample.tcx diff --git a/tests/files/unknown_collision.tcx b/tests/files/tcx/unknown_collision.tcx similarity index 100% rename from tests/files/unknown_collision.tcx rename to tests/files/tcx/unknown_collision.tcx diff --git a/tests/files/vendor_type_attribute.tcx b/tests/files/tcx/vendor_type_attribute.tcx similarity index 100% rename from tests/files/vendor_type_attribute.tcx rename to tests/files/tcx/vendor_type_attribute.tcx diff --git a/tests/test_parse_activity.py b/tests/test_parse_activity.py index fbe5c17..0e845ce 100644 --- a/tests/test_parse_activity.py +++ b/tests/test_parse_activity.py @@ -52,7 +52,7 @@ def test_parse_unsupported_extension(): def test_parse_explicit_ext_overrides_path(tmp_path): # ext takes precedence over the path suffix - src = Path(__file__).parent / "files" / "sample.gpx" + src = Path(__file__).parent / "files" / "gpx" / "sample.gpx" odd_name = tmp_path / "export.dat" odd_name.write_bytes(src.read_bytes()) @@ -64,12 +64,12 @@ def test_tcx_columns_match_selector_order(): # parse_tcx already emits canonical names; ActivityParser only selects/orders them, # dropping any namespace-qualified columns for unrecognized elements. parser = ActivityParser() - records, laps, _ = parser.parse(Path(__file__).parent / "files" / "sample.tcx") + records, laps, _ = parser.parse(Path(__file__).parent / "files" / "tcx" / "sample.tcx") assert list(records.columns) == [c for c in parser.tcx_records_selector if c in records.columns] assert list(laps.columns) == [c for c in parser.tcx_laps_selector if c in laps.columns] def test_gpx_columns_match_selector_order(): parser = ActivityParser() - records, _, _ = parser.parse(Path(__file__).parent / "files" / "sample.gpx") + records, _, _ = parser.parse(Path(__file__).parent / "files" / "gpx" / "sample.gpx") assert list(records.columns) == [c for c in parser.gpx_records_selector if c in records.columns] diff --git a/tests/test_parse_fit.py b/tests/test_parse_fit.py index deb5683..e1bf1d4 100644 --- a/tests/test_parse_fit.py +++ b/tests/test_parse_fit.py @@ -11,7 +11,7 @@ from activity_parser import ActivityParser from activity_parser.parse_fit_file import parse_fit -FILES = Path(__file__).parent / "files" +FILES = Path(__file__).parent / "files" / "fit" EDGE_820 = FILES / "garmin-edge-820-bike.fit" FENIX_5 = FILES / "garmin-fenix-5-bike.fit" diff --git a/tests/test_parse_tcx_gpx.py b/tests/test_parse_tcx_gpx.py index 605e8c4..c5671aa 100644 --- a/tests/test_parse_tcx_gpx.py +++ b/tests/test_parse_tcx_gpx.py @@ -11,28 +11,30 @@ from activity_parser.parse_tcx_gpx import parse_gpx, parse_tcx FILES = Path(__file__).parent / "files" -SAMPLE_TCX = FILES / "sample.tcx" -SAMPLE_GPX = FILES / "sample.gpx" -NO_POSITION_TCX = FILES / "no_position.tcx" -MULTI_SEGMENT_GPX = FILES / "multi_segment.gpx" -NO_TIME_TCX = FILES / "no_time.tcx" -NO_TIME_GPX = FILES / "no_time.gpx" -MIXED_OFFSET_TCX = FILES / "mixed_offset.tcx" -MIXED_OFFSET_GPX = FILES / "mixed_offset.gpx" -BAD_SPEED_GPX = FILES / "bad_speed.gpx" -GPXTPX_V1_GPX = FILES / "gpxtpx_v1.gpx" -GPXDATA_GPX = FILES / "gpxdata.gpx" -UNKNOWN_EXTENSION_GPX = FILES / "unknown_extension.gpx" -GPX10 = FILES / "gpx10.gpx" -RUNNING_TCX = FILES / "running.tcx" -CADENCE_COLLISION_TCX = FILES / "cadence_collision.tcx" -UNKNOWN_COLLISION_TCX = FILES / "unknown_collision.tcx" -MIXED_CONTENT_TCX = FILES / "mixed_content.tcx" -VENDOR_TYPE_ATTRIBUTE_TCX = FILES / "vendor_type_attribute.tcx" -DUPLICATE_CADENCE_TCX = FILES / "duplicate_cadence.tcx" -LAPS_ONLY_TCX = FILES / "laps_only.tcx" -EXTRA_VENDOR_TYPE_ATTRIBUTE_TCX = FILES / "extra_vendor_type_attribute.tcx" -LX_NAMESPACE_RESET_TCX = FILES / "lx_namespace_reset.tcx" +TCX_FILES = FILES / "tcx" +GPX_FILES = FILES / "gpx" +SAMPLE_TCX = TCX_FILES / "sample.tcx" +SAMPLE_GPX = GPX_FILES / "sample.gpx" +NO_POSITION_TCX = TCX_FILES / "no_position.tcx" +MULTI_SEGMENT_GPX = GPX_FILES / "multi_segment.gpx" +NO_TIME_TCX = TCX_FILES / "no_time.tcx" +NO_TIME_GPX = GPX_FILES / "no_time.gpx" +MIXED_OFFSET_TCX = TCX_FILES / "mixed_offset.tcx" +MIXED_OFFSET_GPX = GPX_FILES / "mixed_offset.gpx" +BAD_SPEED_GPX = GPX_FILES / "bad_speed.gpx" +GPXTPX_V1_GPX = GPX_FILES / "gpxtpx_v1.gpx" +GPXDATA_GPX = GPX_FILES / "gpxdata.gpx" +UNKNOWN_EXTENSION_GPX = GPX_FILES / "unknown_extension.gpx" +GPX10 = GPX_FILES / "gpx10.gpx" +RUNNING_TCX = TCX_FILES / "running.tcx" +CADENCE_COLLISION_TCX = TCX_FILES / "cadence_collision.tcx" +UNKNOWN_COLLISION_TCX = TCX_FILES / "unknown_collision.tcx" +MIXED_CONTENT_TCX = TCX_FILES / "mixed_content.tcx" +VENDOR_TYPE_ATTRIBUTE_TCX = TCX_FILES / "vendor_type_attribute.tcx" +DUPLICATE_CADENCE_TCX = TCX_FILES / "duplicate_cadence.tcx" +LAPS_ONLY_TCX = TCX_FILES / "laps_only.tcx" +EXTRA_VENDOR_TYPE_ATTRIBUTE_TCX = TCX_FILES / "extra_vendor_type_attribute.tcx" +LX_NAMESPACE_RESET_TCX = TCX_FILES / "lx_namespace_reset.tcx" # ---------------------------------------------------------------------------