feat(poll): extend response editing contract
This commit is contained in:
36
tests/test_poll_contract.py
Normal file
36
tests/test_poll_contract.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from govoplan_core.core.poll import PollAnswerRef, PollOptionUpdateCommand, PollResponseRef
|
||||
|
||||
|
||||
class PollContractTests(unittest.TestCase):
|
||||
def test_response_ref_remains_backwards_compatible_and_can_carry_answers(self) -> None:
|
||||
submitted_at = datetime(2026, 7, 20, tzinfo=timezone.utc)
|
||||
|
||||
legacy = PollResponseRef(None, submitted_at)
|
||||
detailed = PollResponseRef(
|
||||
invitation_id="invitation-1",
|
||||
submitted_at=submitted_at,
|
||||
respondent_id="person-1",
|
||||
answers=(PollAnswerRef(option_id="option-1", option_key="slot-1", value="available"),),
|
||||
)
|
||||
|
||||
self.assertEqual(legacy.answers, ())
|
||||
self.assertEqual(detailed.answers[0].value, "available")
|
||||
|
||||
def test_option_update_command_is_a_complete_immutable_snapshot(self) -> None:
|
||||
command = PollOptionUpdateCommand(
|
||||
label="Tuesday 10:00",
|
||||
value={"slot_id": "slot-1"},
|
||||
metadata={"source": "scheduling"},
|
||||
)
|
||||
|
||||
self.assertEqual(command.label, "Tuesday 10:00")
|
||||
self.assertEqual(command.value, {"slot_id": "slot-1"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user