Beispiel #1
0
def test_answer_type_annotation_schema_mismatch():
    # Answers to STXT are valid for MTXT as well, that's why STXT is excluded
    # Other than that, each answer is only valid for a single answer type
    unique_answer_types = [
        key for key in ANSWER_TYPE_NAMES_AND_ANSWERS.keys() if key != "STXT"
    ]
    for answer_type in unique_answer_types:
        answer = ANSWER_TYPE_NAMES_AND_ANSWERS[answer_type]
        for answer_type_check in unique_answer_types:
            assert Question(answer_type=answer_type_check).is_answer_valid(
                answer=answer) == (answer_type == answer_type_check)
Beispiel #2
0
def test_new_answer_type_listed():
    q = Question(answer_type="TEST")
    with pytest.raises(RuntimeError):
        q.is_answer_valid(answer="foo")
Beispiel #3
0
def test_answer_type_annotation_schema(answer, answer_type):
    q = Question(answer_type=answer_type)
    assert q.is_answer_valid(answer=answer) is True
Beispiel #4
0
def test_answer_type_annotation_header_schema_fails(answer,
                                                    answer_type: str = "HEAD"):
    q = Question(answer_type=answer_type)
    assert not q.is_answer_valid(answer=answer)
def test_answer_type_allows_null(answer_type, allow_null):
    q = Question(answer_type=answer_type)
    assert q.is_answer_valid(answer=None) == allow_null