Changeset 269fdc2 in flexoentity for tests/conftest.py


Ignore:
Timestamp:
11/06/25 08:23:11 (2 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
master
Children:
182ba7d
Parents:
223c9d5
Message:

adjustments to domain handling - with_domain constructor added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/conftest.py

    r223c9d5 r269fdc2  
    4545        # If no FlexOID yet, generate a draft ID now.
    4646        if not getattr(self, "flexo_id", None):
    47             domain_code = (
    48                 self.domain.domain if isinstance(self.domain, Domain) else "GEN"
    49             )
    5047            self.flexo_id = FlexOID.safe_generate(
    51                 domain=domain_code,
    52                 entity_type=EntityType.ITEM.value,     # 'I'
     48                domain=self.default_domain_code,
     49                entity_type=SingleChoiceQuestion.ENTITY_TYPE.value,     # 'I'
    5350                estate=EntityState.DRAFT.value,        # 'D'
    5451                text=self.text_seed or self.text,
     
    5855    @classmethod
    5956    def default(cls):
    60         return cls(domain=Domain(domain="GEN"))
     57        return cls()
    6158
    6259    def to_dict(self):
     
    8077    @classmethod
    8178    def from_dict(cls, data):
    82         obj = cls(domain=Domain(domain="GEN"),
    83             text=data.get("text", ""),
     79        obj = cls(text=data.get("text", ""),
    8480            options=[AnswerOption.from_dict(o) for o in data.get("options", [])],
    8581        )
    8682        # restore FlexoEntity core fields
    87         obj.domain = data.get("domain")
    8883        if "flexo_id" in data:
    8984            obj.flexo_id = FlexOID.parsed(data["flexo_id"])
     
    9691@pytest.fixture
    9792def sample_question():
    98     q = SingleChoiceQuestion(domain=Domain.default(),
    99                              text="What is 2 + 2?",
     93    q = SingleChoiceQuestion(text="What is 2 + 2?",
    10094                             options=[])
    10195    q._update_fingerprint()
Note: See TracChangeset for help on using the changeset viewer.