Exemple #1
0
def test_get_all_questions_for_block_question_variants():
    block = {
        "id": "block1",
        "type": "Question",
        "title": "Block 1",
        "question_variants": [
            {
                "question": {
                    "id": "question1",
                    "title": "Question 1",
                    "answers": [{"id": "answer1", "label": "Variant 1"}],
                },
                "when": [],
            },
            {
                "question": {
                    "id": "question1",
                    "title": "Question 1",
                    "answers": [{"id": "answer1", "label": "Variant 2"}],
                },
                "when": [],
            },
        ],
    }

    all_questions = QuestionnaireSchema.get_all_questions_for_block(block)

    assert len(all_questions) == 2

    assert all_questions[0]["answers"][0]["label"] == "Variant 1"
    assert all_questions[1]["answers"][0]["label"] == "Variant 2"
Exemple #2
0
def test_get_all_questions_for_block_question():
    block = {
        "id": "block1",
        "type": "Question",
        "title": "Block 1",
        "question": {
            "id": "question1",
            "title": "Question 1",
            "answers": [{"id": "answer1", "label": "Answer 1"}],
        },
    }

    all_questions = QuestionnaireSchema.get_all_questions_for_block(block)

    assert len(all_questions) == 1

    assert all_questions[0]["answers"][0]["id"] == "answer1"
def test_get_all_questions_for_block_empty():
    block = {}

    all_questions = QuestionnaireSchema.get_all_questions_for_block(block)

    assert not all_questions