Changeset 3389960 in flexoentity for tests/test_flexoid.py


Ignore:
Timestamp:
02/27/26 13:47:23 (3 days ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
unify_backends
Children:
c1144fd
Parents:
54941b4
Message:

redesign of Identity and PersistanceBackends - this is a breaking change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test_flexoid.py

    r54941b4 r3389960  
    1313import pytest
    1414from logging import Logger
    15 from flexoentity import FlexOID, canonical_seed
     15from flexoentity import FlexOID, canonical_seed, Domain
    1616
    1717
     
    5151# Generation and deterministic hashing
    5252# ──────────────────────────────────────────────
    53 
    54 def test_generate_and_hash_stability(fixed_datetime):
    55     # Fix the date so test is stable
     53def test_generate_is_not_deterministic(fixed_datetime):
    5654    fid1 = FlexOID.generate("GEN", "I", "D", "test content")
    5755    fid2 = FlexOID.generate("GEN", "I", "D", "test content")
    58     assert fid1 == fid2  # deterministic
    59     assert fid1.hash_part == fid2.hash_part
    60     assert fid1.domain_id == "GEN"
    61     assert fid1.entity_type == "I"
    6256
     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
     63def 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
    6368
    6469def 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
    6877
    6978    repo = DummyRepo()
     79
    7080    fid = FlexOID.safe_generate("GEN", "I", "D", "abc", repo=repo)
     81
    7182    assert isinstance(fid, FlexOID)
     83    assert fid != first
    7284    assert fid.state_code == "D"
    73 
    7485
    7586# ──────────────────────────────────────────────
Note: See TracChangeset for help on using the changeset viewer.