Changeset 8aa20c7 in flexoentity for tests/test_persistance_integrity.py
- Timestamp:
- 11/01/25 15:51:10 (2 months ago)
- Branches:
- master
- Children:
- 5c72356
- Parents:
- ca39274
- File:
-
- 1 edited
-
tests/test_persistance_integrity.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/test_persistance_integrity.py
rca39274 r8aa20c7 6 6 import pytest 7 7 8 from builder.questions import RadioQuestion, AnswerOption9 8 from flexoentity import EntityState, EntityType, Domain 10 9 11 10 @pytest.fixture 12 11 def approved_question(): 13 """Provide a fully approved and published RadioQuestion for persistence tests."""14 q = RadioQuestion(15 domain=Domain(domain="GEN", e type=EntityType.DOMAIN, state=EntityState.DRAFT),16 e type=None, # RadioQuestion sets this internally to EntityType.QUESTION12 """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 17 16 state=EntityState.DRAFT, 18 17 text="What is Ohm’s law?", … … 36 35 json_str = approved_question.to_json() 37 36 print("JSON", json_str) 38 loaded = RadioQuestion.from_json(json_str)37 loaded = SingleChoiceQuestion.from_json(json_str) 39 38 40 39 print("Approved", approved_question.text_seed) 41 40 print("Loaded", loaded.text_seed) 42 41 # Fingerprint and state should match — integrity must pass 43 assert RadioQuestion.verify_integrity(loaded)42 assert SingleChoiceQuestion.verify_integrity(loaded) 44 43 45 44 # Metadata should be preserved exactly … … 56 55 tampered_json = json.dumps(tampered) 57 56 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) 60 59 61 60 @pytest.mark.skip(reason="FlexOIDs regenerated on import; corruption detection not yet applicable") … … 70 69 file.write_text(corrupted) 71 70 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.
