feat: parse and validate FIT containers

This commit is contained in:
Bastian Wagner
2026-08-15 10:27:05 +02:00
parent 4599b2b71c
commit a47ad77071
4 changed files with 212 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
from pathlib import Path
import pytest
from app.fit.rewriter import FitFormatError, is_fit_file
from tests.fit.builders import make_fit
def test_valid_12_and_14_byte_headers(tmp_path: Path) -> None:
for size in (12, 14):
path = tmp_path / f"valid-{size}.fit"
path.write_bytes(make_fit(b"", header_size=size))
assert is_fit_file(path) is True
def test_bad_file_crc_is_rejected(tmp_path: Path) -> None:
payload = bytearray(make_fit(b""))
payload[-1] ^= 0xFF
path = tmp_path / "bad.fit"
path.write_bytes(payload)
assert is_fit_file(path) is False