feat: parse and validate FIT containers
This commit is contained in:
21
tests/fit/test_rewriter_validation.py
Normal file
21
tests/fit/test_rewriter_validation.py
Normal 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
|
||||
Reference in New Issue
Block a user