def test_get_answer_no_list(basic_answer_store): assert basic_answer_store.get_answer("answer3") == Answer.from_dict({ "answer_id": "answer3", "list_item_id": None, "value": 30 })
def test_get_answer_with_list(basic_answer_store): assert basic_answer_store.get_answer("answer1", "abc123") == Answer.from_dict({ "answer_id": "answer1", "list_item_id": "abc123", "value": 10 })
def test_list_serialisation(store_to_serialise): serialised_store = list(store_to_serialise) assert serialised_store == [ Answer.from_dict({ "answer_id": "answer1", "value": 10, "list_item_id": "abc123" }), Answer.from_dict({ "answer_id": "answer2", "value": 20, "list_item_id": "xyz987" }), Answer.from_dict({ "answer_id": "answer3", "value": 30, "list_item_id": None }), ]
def test_from_dict(): test_answer = {"answer_id": "test1", "value": "avalue", "list_item_id": "123321"} expected_answer = Answer(answer_id="test1", value="avalue", list_item_id="123321") assert Answer.from_dict(test_answer) == expected_answer