4e0db55f03
Engine asked_probe_keys no longer include varga split hashes that 400 the scorer, failed compares become visible and retry, user stop can still deliver a range on a stale snapshot, and holdout no longer reasks domains already in the ledger. Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from datetime import date
|
|
|
|
from scripts.rectification.contracts import normalize_rectification_request
|
|
|
|
EVENT_ID = "00000000-0000-4000-8000-000000000001"
|
|
VARGA_SPLIT_HASH = (
|
|
"04:45-05:15:04:47,04:51,04:53,04:59,05:00,05:06,05:08,05:13,05:15"
|
|
":varga.d9.04:47|04:51/05:00|05:06|04:59|04:53/05:08|05:13|05:15"
|
|
)
|
|
|
|
|
|
def request():
|
|
return {
|
|
"birth_date": "1997-08-08",
|
|
"start_time": "05:13",
|
|
"end_time": "05:15",
|
|
"lat": 36.419,
|
|
"lon": 114.213,
|
|
"tz": 8,
|
|
"events": [{
|
|
"id": EVENT_ID,
|
|
"domain": "education",
|
|
"event_kind": "education_milestone",
|
|
"date_start": "2016-09-01",
|
|
"date_end": "2016-09-30",
|
|
"precision": "month",
|
|
"summary": "大学入学",
|
|
}],
|
|
}
|
|
|
|
|
|
class RectificationInputContractTest(unittest.TestCase):
|
|
def test_canonical_varga_split_hash_is_128_characters(self):
|
|
self.assertEqual(len(VARGA_SPLIT_HASH), 128)
|
|
|
|
def test_128_char_asked_probe_key_is_kept(self):
|
|
cleaned = normalize_rectification_request(
|
|
{**request(), "asked_probe_keys": [VARGA_SPLIT_HASH]},
|
|
today=date(2026, 7, 28),
|
|
)
|
|
self.assertIn(VARGA_SPLIT_HASH, cleaned["asked_probe_keys"])
|
|
self.assertNotIn("dropped_asked_probe_keys", cleaned)
|
|
|
|
def test_asked_probe_key_over_200_is_skipped_and_counted(self):
|
|
long_key = "k" * 201
|
|
cleaned = normalize_rectification_request(
|
|
{**request(), "asked_probe_keys": [long_key, "career.2018.05.dasha_boundary"]},
|
|
today=date(2026, 7, 28),
|
|
)
|
|
self.assertEqual(cleaned["asked_probe_keys"], ["career.2018.05.dasha_boundary"])
|
|
self.assertEqual(cleaned["dropped_asked_probe_keys"], 1)
|
|
|
|
def test_empty_asked_probe_key_is_still_rejected(self):
|
|
with self.assertRaises(ValueError):
|
|
normalize_rectification_request(
|
|
{**request(), "asked_probe_keys": [" "]},
|
|
today=date(2026, 7, 28),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|