Esempio n. 1
0
def test_repeat_row():
    """If the same requirement id is present twice, raise an exception"""
    assert Requirement.objects.count() == 0

    processor = import_reqs.RowProcessor()
    processor.policies = Mock(**{'from_row.return_value': mommy.make(Policy)})
    row = {
        'reqId': '13.37',
        'issuingBody': 'body',
        'policySection': 'None',
        'policySubSection': 'None',
        'reqText': 'texttexttext',
        'verb': 'shall',
        'Impacted Entity': 'something',
        'reqDeadline': 'N/A',
        'citation': 'N/A'
    }
    processor.add(row)
    assert Requirement.objects.count() == 1
    assert Requirement.objects.first().issuing_body == 'body'

    with pytest.raises(ValueError):
        processor.add(row)

    row['issuingBody'] = 'body2'
    processor2 = import_reqs.RowProcessor()
    processor2.policies = processor.policies
    # Different processor, so we don't raise an exception, we just modify the
    # existing entry
    processor2.add(row)
    assert Requirement.objects.count() == 1
    assert Requirement.objects.first().issuing_body == 'body2'
Esempio n. 2
0
def test_bad_requirement_ids_raise_value_error(requirement_id):
    processor = import_reqs.RowProcessor()
    processor.policies = Mock(**{'from_row.return_value': mommy.make(Policy)})
    row = {
        'policySection': 'None',
        'policySubSection': 'None',
        'reqDeadline': 'N/A',
        'reqText': 'texttexttext',
        'reqId': requirement_id,
    }
    with pytest.raises(ValueError):
        processor.add(row)
Esempio n. 3
0
def test_varying_requirement_headers(verb_field, reqid_field, entity_field,
                                     citation_field):
    processor = import_reqs.RowProcessor()
    processor.policies = Mock(**{'from_row.return_value': mommy.make(Policy)})
    row = {
        'policySection': 'None',
        'policySubSection': 'None',
        'reqDeadline': 'N/A',
        'reqText': 'texttexttext',
    }
    row[citation_field] = 'N/A'
    row[entity_field] = 'something'
    row[reqid_field] = '13.37'
    row[verb_field] = 'shall'
    processor.add(row)
    assert Requirement.objects.count() == 1
    assert Requirement.objects.first().citation == 'N/A'
    assert Requirement.objects.first().impacted_entity == 'something'
    assert Requirement.objects.first().req_id == '13.37'
    assert Requirement.objects.first().verb == 'shall'