Example #1
0
def test_invalid_list_collector_duplicate_ids_between_list_collectors():
    filename = "schemas/invalid/test_invalid_list_collector_duplicate_ids_multiple_collectors.json"

    validator = QuestionnaireValidator(_open_and_load_schema_file(filename))
    validator.validate_duplicates()

    expected_errors = [
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "add-person"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "remove-person"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "edit-person"
        },
    ]

    assert all({
        expected_error in validator.errors
        for expected_error in expected_errors
    })
Example #2
0
def test_duplicate_answer_ids():
    filename = "schemas/invalid/test_invalid_duplicate_ids.json"

    validator = QuestionnaireValidator(_open_and_load_schema_file(filename))
    validator.validate_duplicates()

    expected_errors = [
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "block-1"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "answer-2"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "question-1"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "block-2"
        },
        {
            "message": error_messages.DUPLICATE_ID_FOUND,
            "id": "block-and-question"
        },
    ]

    assert all({
        expected_error in validator.errors
        for expected_error in expected_errors
    })