Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/files/README.md
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_parse_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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]
2 changes: 1 addition & 1 deletion tests/test_parse_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
46 changes: 24 additions & 22 deletions tests/test_parse_tcx_gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


# ---------------------------------------------------------------------------
Expand Down