gabriel / musehub public
test_coord_record_id.py python
44 lines 1.2 KB
Raw
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor ⚠ breaking 20 days ago
1 """MusehubCoordRecord.record_id must be String(128) not String(36).
2
3 record_uuid was a misnomer — the field stores sha256: genesis IDs
4 (71 chars for reservations/tasks/intents) and opaque run_id strings,
5 not random 36-char strings. This guards the rename and the column width.
6 """
7 from __future__ import annotations
8
9 import pytest
10 from sqlalchemy import String
11
12 from musehub.db.coord_models import MusehubCoordRecord
13
14
15 def _col(name: str) -> None:
16 return MusehubCoordRecord.__table__.columns[name]
17
18
19 def test_record_id_column_exists() -> None:
20 assert "record_id" in MusehubCoordRecord.__table__.columns
21
22
23 def test_record_uuid_column_gone() -> None:
24 assert "record_uuid" not in MusehubCoordRecord.__table__.columns
25
26
27 def test_record_id_is_string_128() -> None:
28 col = _col("record_id")
29 assert isinstance(col.type, String)
30 assert col.type.length == 128
31
32
33 def test_record_id_not_nullable() -> None:
34 assert _col("record_id").nullable is False
35
36
37 def test_unique_constraint_uses_record_id() -> None:
38 constraint_cols = {
39 col.name
40 for c in MusehubCoordRecord.__table__.constraints
41 for col in getattr(c, "columns", [])
42 }
43 assert "record_id" in constraint_cols
44 assert "record_uuid" not in constraint_cols
File History 1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595 fix: typing audit — 0 violations, 0 untyped defs across all… Sonnet 4.6 minor 20 days ago