source: flexoentity/tests/conftest.py@ 02d288d

Last change on this file since 02d288d was 02d288d, checked in by Enrico Schwass <ennoausberlin@…>, 3 months ago

improve hash generation and collision handler - move signature from FlexOID to FlexoEntity

  • Property mode set to 100644
File size: 1.9 KB
Line 
1# tests/conftest.py
2
3import pytest
4import json
5from flexoentity import FlexoEntity, EntityType, EntityState, Domain
6
7import pytest
8import json
9from flexoentity import EntityType, EntityState, Domain
10from builder.questions import RadioQuestion, AnswerOption # adjust path if different
11from builder.media_items import NullMediaItem # adjust import if needed
12
13
14@pytest.fixture(scope="session")
15def domain():
16 """Provide a reusable domain for all entity tests."""
17 return Domain(
18 domain="SIG",
19 etype=EntityType.DOMAIN,
20 state=EntityState.DRAFT,
21 fullname="Signal Corps",
22 description="Questions related to communications and signaling systems.",
23 classification="RESTRICTED",
24 owner="test-suite"
25 )
26
27
28@pytest.fixture
29def radio_question(domain):
30 """Return a simple RadioQuestion entity for testing FlexoEntity logic."""
31 q = RadioQuestion(
32 domain=domain,
33 etype=EntityType.QUESTION,
34 state=EntityState.DRAFT,
35 text="Which frequency band is used for shortwave communication?",
36 options=[
37 AnswerOption(id="opt1", text="HF (3–30 MHz)", points=1),
38 AnswerOption(id="opt2", text="VHF (30–300 MHz)", points=0),
39 AnswerOption(id="opt3", text="UHF (300–3000 MHz)", points=0),
40 ]
41 )
42 return q
43
44
45@pytest.fixture
46def serialized_question(radio_question):
47 """Provide the serialized JSON form for roundtrip tests."""
48 return radio_question.to_json()
49
50
51@pytest.fixture
52def deserialized_question(serialized_question):
53 """Recreate a question from JSON for consistency tests."""
54 return RadioQuestion.from_json(serialized_question)
55
56
57@pytest.fixture
58def null_media():
59 """Provide a default NullMediaItem instance for media tests."""
60 return NullMediaItem(
61 domain=domain,
62 etype=EntityType.MEDIA,
63 state=EntityState.DRAFT
64 )
Note: See TracBrowser for help on using the repository browser.