|
| 1 | +"""Use a source chip year when a normalized SoC date is a later placeholder.""" |
| 2 | + |
| 3 | +from app.verify import offline |
| 4 | +from app.verify.common import Record, foreign_key_sets |
| 5 | + |
| 6 | + |
| 7 | +def _release_for(release_date: str, raw_chipset: str | None) -> str: |
| 8 | + soc = Record("soc", "soc/chip-x.json", { |
| 9 | + "slug": "chip-x", "release_date": release_date, "raw_chipset": raw_chipset, |
| 10 | + }) |
| 11 | + return foreign_key_sets({"soc": [soc]})[2]["chip-x"] |
| 12 | + |
| 13 | + |
| 14 | +def test_earlier_structured_chip_year_corrects_late_placeholder(): |
| 15 | + assert _release_for( |
| 16 | + "2025-01-01", "Qualcomm Snapdragon 680 SM6225, 2021, 64 bit, octa-core" |
| 17 | + ) == "2021-01-01" |
| 18 | + |
| 19 | + phone = Record("smartphone", "smartphone/phone-x.json", { |
| 20 | + "slug": "phone-x", "soc": "chip-x", "release_date": "2022-08-01", |
| 21 | + "source_urls": ["https://www.qualcomm.com/products/mobile/snapdragon"], |
| 22 | + }) |
| 23 | + before = offline.score_record(phone, 2026, {"chip-x": "2025-01-01"}) |
| 24 | + after = offline.score_record(phone, 2026, {"chip-x": "2021-01-01"}) |
| 25 | + assert "soc_not_after_device" in before.flags |
| 26 | + assert "soc_not_after_device" not in after.flags |
| 27 | + |
| 28 | + |
| 29 | +def test_precise_or_unstructured_dates_keep_the_normalized_date(): |
| 30 | + assert _release_for("2024-05-07", "Chip X, 2021, 8 cores") == "2024-05-07" |
| 31 | + assert _release_for("2025-01-01", "Chip X with 2021 revision") == "2025-01-01" |
| 32 | + assert _release_for("2025-01-01", None) == "2025-01-01" |
| 33 | + assert _release_for("2025-01-01", "Chip X, 2026, 8 cores") == "2025-01-01" |
| 34 | + |
| 35 | + |
| 36 | +def test_raw_chip_year_still_flags_a_genuine_era_mismatch(): |
| 37 | + release = _release_for( |
| 38 | + "2024-01-01", "Qualcomm Snapdragon 8s Gen 3 SM8635, 2024, 8 cores" |
| 39 | + ) |
| 40 | + phone = Record("smartphone", "smartphone/phone-x.json", { |
| 41 | + "slug": "phone-x", "soc": "chip-x", "release_date": "2015-01-09", |
| 42 | + }) |
| 43 | + score = offline.score_record(phone, 2026, {"chip-x": release}) |
| 44 | + assert "soc_not_after_device" in score.flags |
0 commit comments