22 lines
598 B
Python
22 lines
598 B
Python
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
|