Пример #1
0
def test_checkbox_can_only_answer_other_if_has_other_option(
        checkbox_questions):
    for question in checkbox_questions:
        question_obj = CheckboxQuestion(question["tree"])

        if question_obj.has_other_option:
            question_obj.answer_other("abc")
        else:
            with pytest.raises(ValueError):
                question_obj.answer_other("abc")
Пример #2
0
def test_checkbox_serializes_other_option(checkbox_questions):
    for question in checkbox_questions:
        question_obj = CheckboxQuestion(question["tree"])

        other_option_key = question_obj.id + ".other_option_response"

        if not question_obj.has_other_option:
            serialized = question_obj.serialize()
            assert other_option_key not in serialized
        else:
            question_obj.answer_other("abc")
            serialized = question_obj.serialize()
            assert other_option_key in serialized