def test_add_failed_questions_incomplete_declaration():
    failed_questions_adder = export_dos_suppliers.add_failed_questions(None)

    record = failed_questions_adder({'declaration': {'status': 'started'}})

    assert record['failed_mandatory'] == ['INCOMPLETE']
    assert record['discretionary'] == []
def test_add_failed_question_mandatory_true_is_false(get_declaration_questions):
    get_declaration_questions.return_value = [
        (Mock(number=17), True)
    ]

    failed_questions_adder = export_dos_suppliers.add_failed_questions(None)

    record = failed_questions_adder({'declaration': {'status': 'complete'}})

    assert record['failed_mandatory'] == ['Q17']
def test_add_failed_question_mandatory_liability_insurance(get_declaration_questions):
    get_declaration_questions.return_value = [
        (Mock(number=14), "Invalid")
    ]

    failed_questions_adder = export_dos_suppliers.add_failed_questions(None)

    record = failed_questions_adder({'declaration': {'status': 'complete'}})

    assert record['failed_mandatory'] == ['Q14']
def test_add_failed_questions(get_declaration_questions):
    get_declaration_questions.return_value = [
        (Mock(number=i), True) for i in chain(range(1, 14), range(15, 17), range(38, 55))
    ] + [
        (Mock(number=i), False) for i in chain(range(17, 21), range(21, 37))
    ] + [
        (Mock(number=14), CORRECT_DECLARATION_RESPONSES[14][0])
    ]

    failed_questions_adder = export_dos_suppliers.add_failed_questions(None)

    record = failed_questions_adder({'declaration': {'status': 'complete'}})

    assert record['failed_mandatory'] == []
    assert len(record['discretionary']) == 16