Changeset ef964d8 in flexoentity for tests/test_id_stress.py


Ignore:
Timestamp:
11/27/25 18:12:23 (7 weeks ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
4e11d58
Parents:
9a50e0b
Message:

new serialization structure adopted and tests fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test_id_stress.py

    r9a50e0b ref964d8  
    99
    1010import pytest
    11 
    12 from flexoentity import FlexOID, EntityType, EntityState
     11from uuid import uuid4
     12from flexoentity import FlexOID, EntityType, EntityState, FlexoSignature
    1313
    1414logger = logging.getLogger(__name__)
     
    6666    assert id1 == id2
    6767
     68def test_massive_lifecycle_simulation(cert_ref_linux, sample_domain):
     69    """
     70    Generate 100 random FlexoSignatures, mutate content, run through lifecycle,
     71    and ensure all FlexOIDs are unique and valid.
     72    """
     73    entities = []
    6874
    69 def test_massive_lifecycle_simulation(sample_question):
    70     """
    71     Generate 100 random SingleChoiceQuestions, simulate multiple edits and state transitions,
    72     ensure all final IDs and fingerprints are unique and valid.
    73     """
    74     entities = [
    75         copy.deepcopy(sample_question) for _ in range(100)
    76     ]
     75    for i in range(100):
     76        sig = FlexoSignature.with_domain_id(
     77            domain_id="SIGTEST",
     78            signed_entity=sample_domain.flexo_id,
     79            signer_id=uuid4(),
     80            certificate_reference=cert_ref_linux,
     81            comment=f"Initial signature #{i}"
     82        )
     83        entities.append(sig)
    7784
     85    # Mutate + lifecycle transitions
    7886    for i, e in enumerate(entities):
    79         # random edit
    80         e.text += f" updated #{i}"
     87        # CONTENT CHANGE → fingerprint changes → hash → FlexOID.prefix changes
     88        e.comment += f" updated-{i}"
    8189        e._update_fingerprint()
    8290
     
    8896            e.publish()
    8997
    90     flexoids = [e.flexo_id for e in entities]
    91     assert len(flexoids) == len(set(flexoids)), "Duplicate FlexOIDs after lifecycle simulation"
     98    # Check ID uniqueness
     99    flexoids = [str(e.flexo_id) for e in entities]
     100    assert len(flexoids) == len(set(flexoids)), "Duplicate FlexOIDs detected"
Note: See TracChangeset for help on using the changeset viewer.