-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quint_fingerprint.py
More file actions
39 lines (31 loc) · 1.14 KB
/
Copy pathtest_quint_fingerprint.py
File metadata and controls
39 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import unittest
from pathlib import Path
from uuid import uuid4
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from runtime import storage # noqa: E402
from runtime.quint import fingerprint # noqa: E402
def _sandbox_root() -> Path:
root = ROOT / "runs" / "tmp-tests" / uuid4().hex
root.mkdir(parents=True, exist_ok=True)
return root
class QuintFingerprintTests(unittest.TestCase):
def test_fingerprint_store_records(self) -> None:
root = _sandbox_root()
run_dir = storage.init_run_dir(root, "run-fp")
store = fingerprint.FingerprintStore(run_dir)
fp = fingerprint.build_fingerprint(
step_id="step-1",
shard_ids=["s1"],
cache_keys=["cache-1"],
token_budget_used=10,
token_budget_total=50,
)
recorded = store.record(fp)
self.assertEqual(recorded["fingerprint_id"], fp.fingerprint_id)
latest = store.get_latest_for_step("step-1")
self.assertIsNotNone(latest)
self.assertEqual(latest["fingerprint_id"], fp.fingerprint_id)
if __name__ == "__main__":
unittest.main()