Changeset 8aa20c7 in flexoentity for tests/test_persistance_integrity.py


Ignore:
Timestamp:
11/01/25 15:51:10 (2 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
5c72356
Parents:
ca39274
Message:

full refactoring of FlexOID

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test_persistance_integrity.py

    rca39274 r8aa20c7  
    66import pytest
    77
    8 from builder.questions import RadioQuestion, AnswerOption
    98from flexoentity import EntityState, EntityType, Domain
    109
    1110@pytest.fixture
    1211def approved_question():
    13     """Provide a fully approved and published RadioQuestion for persistence tests."""
    14     q = RadioQuestion(
    15         domain=Domain(domain="GEN", etype=EntityType.DOMAIN, state=EntityState.DRAFT),
    16         etype=None,  # RadioQuestion sets this internally to EntityType.QUESTION
     12    """Provide a fully approved and published SingleChoiceQuestion for persistence tests."""
     13    q = SingleChoiceQuestion(
     14        domain=Domain(domain="GEN", entity_type=EntityType.DOMAIN, state=EntityState.DRAFT),
     15        entity_type=None,  # SingleChoiceQuestion sets this internally to EntityType.ITEM
    1716        state=EntityState.DRAFT,
    1817        text="What is Ohm’s law?",
     
    3635    json_str = approved_question.to_json()
    3736    print("JSON", json_str)
    38     loaded = RadioQuestion.from_json(json_str)
     37    loaded = SingleChoiceQuestion.from_json(json_str)
    3938
    4039    print("Approved", approved_question.text_seed)
    4140    print("Loaded", loaded.text_seed)
    4241    # Fingerprint and state should match — integrity must pass
    43     assert RadioQuestion.verify_integrity(loaded)
     42    assert SingleChoiceQuestion.verify_integrity(loaded)
    4443
    4544    # Metadata should be preserved exactly
     
    5655    tampered_json = json.dumps(tampered)
    5756
    58     loaded = RadioQuestion.from_json(tampered_json)
    59     assert not RadioQuestion.verify_integrity(loaded)
     57    loaded = SingleChoiceQuestion.from_json(tampered_json)
     58    assert not SingleChoiceQuestion.verify_integrity(loaded)
    6059
    6160@pytest.mark.skip(reason="FlexOIDs regenerated on import; corruption detection not yet applicable")
     
    7069    file.write_text(corrupted)
    7170
    72     loaded = RadioQuestion.from_json(file.read_text())
    73     assert not RadioQuestion.verify_integrity(loaded)
     71    loaded = SingleChoiceQuestion.from_json(file.read_text())
     72    assert not SingleChoiceQuestion.verify_integrity(loaded)
Note: See TracChangeset for help on using the changeset viewer.