Changeset ca39274 in flexoentity for tests/test_persistance_integrity.py
- Timestamp:
- 10/28/25 12:16:31 (3 months ago)
- Branches:
- master
- Children:
- 8aa20c7
- Parents:
- 52ccac6
- File:
-
- 1 edited
-
tests/test_persistance_integrity.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/test_persistance_integrity.py
r52ccac6 rca39274 6 6 import pytest 7 7 8 from flexoentity import EntityState9 8 from builder.questions import RadioQuestion, AnswerOption 9 from flexoentity import EntityState, EntityType, Domain 10 10 11 12 # ──────────────────────────────────────────────────────────────────────────────13 11 @pytest.fixture 14 def approved_question( domain):12 def approved_question(): 15 13 """Provide a fully approved and published RadioQuestion for persistence tests.""" 16 14 q = RadioQuestion( 17 domain= domain,15 domain=Domain(domain="GEN", etype=EntityType.DOMAIN, state=EntityState.DRAFT), 18 16 etype=None, # RadioQuestion sets this internally to EntityType.QUESTION 19 17 state=EntityState.DRAFT, 20 18 text="What is Ohm’s law?", 21 19 options=[ 22 AnswerOption( text="U = R × I", points=1),23 AnswerOption( text="U = I / R", points=0),24 AnswerOption( text="R = U × I", points=0),20 AnswerOption(id="OP1", text="U = R × I", points=1), 21 AnswerOption(id="OP2", text="U = I / R", points=0), 22 AnswerOption(id="OP3", text="R = U × I", points=0), 25 23 ], 26 24 ) … … 37 35 """ 38 36 json_str = approved_question.to_json() 37 print("JSON", json_str) 39 38 loaded = RadioQuestion.from_json(json_str) 40 39 40 print("Approved", approved_question.text_seed) 41 print("Loaded", loaded.text_seed) 41 42 # Fingerprint and state should match — integrity must pass 42 43 assert RadioQuestion.verify_integrity(loaded) … … 46 47 assert approved_question.flexo_id == loaded.flexo_id 47 48 assert loaded.state == approved_question.state 48 49 50 # ──────────────────────────────────────────────────────────────────────────────51 49 52 50 @pytest.mark.skip(reason="FlexOIDs regenerated on import; tampering detection not yet implemented") … … 60 58 loaded = RadioQuestion.from_json(tampered_json) 61 59 assert not RadioQuestion.verify_integrity(loaded) 62 63 64 # ──────────────────────────────────────────────────────────────────────────────65 60 66 61 @pytest.mark.skip(reason="FlexOIDs regenerated on import; corruption detection not yet applicable")
Note:
See TracChangeset
for help on using the changeset viewer.
