Changeset 3389960 in flexoentity for tests/test_flexoid.py
- Timestamp:
- 02/27/26 13:47:23 (3 days ago)
- Branches:
- unify_backends
- Children:
- c1144fd
- Parents:
- 54941b4
- File:
-
- 1 edited
-
tests/test_flexoid.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/test_flexoid.py
r54941b4 r3389960 13 13 import pytest 14 14 from logging import Logger 15 from flexoentity import FlexOID, canonical_seed 15 from flexoentity import FlexOID, canonical_seed, Domain 16 16 17 17 … … 51 51 # Generation and deterministic hashing 52 52 # ────────────────────────────────────────────── 53 54 def test_generate_and_hash_stability(fixed_datetime): 55 # Fix the date so test is stable 53 def test_generate_is_not_deterministic(fixed_datetime): 56 54 fid1 = FlexOID.generate("GEN", "I", "D", "test content") 57 55 fid2 = FlexOID.generate("GEN", "I", "D", "test content") 58 assert fid1 == fid2 # deterministic59 assert fid1.hash_part == fid2.hash_part60 assert fid1.domain_id == "GEN"61 assert fid1.entity_type == "I"62 56 57 assert fid1 != fid2 58 assert fid1.domain_id == fid2.domain_id == "GEN" 59 assert fid1.entity_type == fid2.entity_type == "I" 60 assert fid1.version == fid2.version == 1 61 assert fid1.state_code == fid2.state_code == "D" 62 63 def test_fingerprint_is_stable(): 64 d1 = Domain.with_domain_id("GEN", fullname="A", description="B") 65 d2 = Domain.from_dict(d1.to_dict()) 66 67 assert d1.fingerprint == d2.fingerprint 63 68 64 69 def test_safe_generate_collision(monkeypatch): 65 # Fake repo that always returns a conflicting item with different seed 66 class DummyRepo(dict): 67 def get(self, key): return True 70 first = FlexOID.generate("GEN", "I", "D", "abc") 71 72 class DummyRepo: 73 def get(self, key): 74 if key == str(first): 75 return True 76 return None 68 77 69 78 repo = DummyRepo() 79 70 80 fid = FlexOID.safe_generate("GEN", "I", "D", "abc", repo=repo) 81 71 82 assert isinstance(fid, FlexOID) 83 assert fid != first 72 84 assert fid.state_code == "D" 73 74 85 75 86 # ──────────────────────────────────────────────
Note:
See TracChangeset
for help on using the changeset viewer.
