| 1 | # tests/conftest.py
|
|---|
| 2 |
|
|---|
| 3 | import pytest
|
|---|
| 4 | import json
|
|---|
| 5 | from flexoentity import FlexoEntity, EntityType, EntityState, Domain
|
|---|
| 6 |
|
|---|
| 7 | import pytest
|
|---|
| 8 | import json
|
|---|
| 9 | from flexoentity import EntityType, EntityState, Domain
|
|---|
| 10 | from builder.questions import RadioQuestion, AnswerOption # adjust path if different
|
|---|
| 11 | from builder.media_items import NullMediaItem # adjust import if needed
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | @pytest.fixture(scope="session")
|
|---|
| 15 | def 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
|
|---|
| 29 | def 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
|
|---|
| 46 | def serialized_question(radio_question):
|
|---|
| 47 | """Provide the serialized JSON form for roundtrip tests."""
|
|---|
| 48 | return radio_question.to_json()
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | @pytest.fixture
|
|---|
| 52 | def 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
|
|---|
| 58 | def 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 | )
|
|---|