test_encode_6400_hex.py 1019 B

12345678910111213141516171819202122232425262728
  1. from pathlib import Path
  2. import pytest
  3. from tools.encode_6400_hex import Encoder
  4. ROOT = Path(__file__).resolve().parents[2]
  5. def test_set_all_pid_and_get_match_generated_golden_vectors() -> None:
  6. encoder = Encoder()
  7. golden = encoder.contract["golden_vectors"]["frames"]
  8. assert encoder.set_all("6400-front-rear", [0] * 24, [20] * 4, [20] * 4).hex().upper() == golden["set_all_safe"]
  9. assert encoder.set_pid_target("6400-front-rear", 70).hex().upper() == golden["set_pid_target_70"]
  10. assert encoder.get_snapshot("6400-front-rear").hex().upper() == golden["get_snapshot"]
  11. def test_single_product_rejects_reserved_stimulus() -> None:
  12. encoder = Encoder()
  13. with pytest.raises(ValueError, match="not supported"):
  14. encoder.set_stimulus("6400-front-rear", 1, [0] * 24, [0] * 4, [0] * 4)
  15. def test_only_canonical_profile_names_are_accepted() -> None:
  16. encoder = Encoder()
  17. with pytest.raises(ValueError, match="unknown canonical profile"):
  18. encoder.get_snapshot("production")