本文整理汇总了Python中tests.unit.dataactvalidator.utils.number_of_errors函数的典型用法代码示例。如果您正苦于以下问题:Python number_of_errors函数的具体用法?Python number_of_errors怎么用?Python number_of_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了number_of_errors函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ignored_and_failed_original_loan_subsidy_cost_values
def test_ignored_and_failed_original_loan_subsidy_cost_values(database):
""" Tests that a single warning is thrown for both a federal action obligation of 0
and an original loan subsidy cost of 0 """
tas = _TAS
afa = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
original_loan_subsidy_cost='0', assistance_type='09')
afa_2 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
original_loan_subsidy_cost='-2.3', assistance_type='09')
afa_3 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
original_loan_subsidy_cost='2.3', assistance_type='08')
af = AwardFinancialFactory(tas=tas, submisson_id=afa.submission_id, fain=None, uri=None)
errors = number_of_errors(_FILE, database, models=[afa, af, afa_2, afa_3])
assert errors == 3
# Test that this is ignored if assistance type is 08
afa = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
original_loan_subsidy_cost='0', assistance_type='08')
afa_2 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
original_loan_subsidy_cost='-2.3', assistance_type='08')
af = AwardFinancialFactory(tas=tas, submisson_id=afa.submission_id, fain=None, uri=None)
errors = number_of_errors(_FILE, database, models=[afa, af, afa_2])
assert errors == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_c9_award_financial.py
示例2: test_failure
def test_failure(database):
""" Test invalid. For ActionType = A, the CFDA_Number must be active as of the ActionDate.
Not apply to those with CorrectionLateDeleteIndicator = C.
If publish_date > action_date > archive_date, reject that (not active).
"""
cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
action_type='A', correction_late_delete_ind="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
action_type='A', correction_late_delete_ind=None)
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
action_type='A', correction_late_delete_ind="B")
det_award_4 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
action_type='A', correction_late_delete_ind=None)
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, cfda])
assert errors == 4
# test for cfda_number that doesn't exist in the table
cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="54.321", action_date='20140111',
action_type='A', correction_late_delete_ind="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="AB.CDE", action_date='20140111',
action_type='A', correction_late_delete_ind=None)
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="11.111", action_date='20130528',
action_type='B', correction_late_delete_ind="B")
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
assert errors == 3
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:30,代码来源:test_fabs37_detached_award_financial_assistance_1.py
示例3: test_failure
def test_failure(database):
""" Test failure for unique PIID, or combination of PIID/ParentAwardId, from file C exists in file D1 during the
same reporting period. Do not process if allocation transfer agency is not null and does not match agency ID """
# Perform when there's a transaction obligated amount value in the field
af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_parent_award_id',
allocation_transfer_agency=None, transaction_obligated_amou='12345')
ap = AwardProcurementFactory(piid='some_other_piid', parent_award_id='some_parent_award_id')
assert number_of_errors(_FILE, database, models=[af, ap]) == 1
# Perform when there's an ata in the field and it matches the aid
af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_parent_award_id',
allocation_transfer_agency='bad', agency_identifier='bad',
transaction_obligated_amou='12345')
ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_other_parent_award_id')
assert number_of_errors(_FILE, database, models=[af, ap]) == 1
af = AwardFinancialFactory(piid='some_piid', parent_award_id=None,
allocation_transfer_agency='bad', agency_identifier='bad',
transaction_obligated_amou='12345')
ap = AwardProcurementFactory(piid='some_other_piid', parent_award_id='some_other_parent_award_id')
assert number_of_errors(_FILE, database, models=[af, ap]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_c11_cross_file.py
示例4: test_failure
def test_failure(database):
""" BusinessTypes must be one to three letters in length. BusinessTypes values must be non-repeated letters
from A to X. """
# Test if it's somehow empty or has 4 letters (length test)
det_award = DetachedAwardFinancialAssistanceFactory(business_types="")
det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="ABCD")
errors = number_of_errors(_FILE, database, models=[det_award, det_award_2])
assert errors == 2
# Test repeats
det_award = DetachedAwardFinancialAssistanceFactory(business_types="BOb")
det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="BOB")
det_award_3 = DetachedAwardFinancialAssistanceFactory(business_types="BbO")
det_award_4 = DetachedAwardFinancialAssistanceFactory(business_types="BB")
errors = number_of_errors(_FILE, database, models=[det_award, det_award_2, det_award_3, det_award_4])
assert errors == 4
# Test that only valid letters work
det_award = DetachedAwardFinancialAssistanceFactory(business_types="ABY")
det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="C2")
errors = number_of_errors(_FILE, database, models=[det_award, det_award_2])
assert errors == 2
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:26,代码来源:test_fabs18_detached_award_financial_assistance.py
示例5: test_failure
def test_failure(database):
""" Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided and
by_direct_reimbursable_fun is empty the rule fails """
op_dict = {'by_direct_reimbursable_fun': None, 'object_class': 123, 'ussgl480100_undelivered_or_fyb': None,
'ussgl480100_undelivered_or_cpe': None, 'ussgl488100_upward_adjustm_cpe': None,
'ussgl490100_delivered_orde_fyb': None, 'ussgl490100_delivered_orde_cpe': None,
'ussgl498100_upward_adjustm_cpe': None, 'ussgl480200_undelivered_or_fyb': None,
'ussgl480200_undelivered_or_cpe': None, 'ussgl488200_upward_adjustm_cpe': None,
'ussgl490200_delivered_orde_cpe': None, 'ussgl490800_authority_outl_fyb': None,
'ussgl490800_authority_outl_cpe': None, 'ussgl498200_upward_adjustm_cpe': None}
keys = ['ussgl480100_undelivered_or_fyb', 'ussgl480100_undelivered_or_cpe',
'ussgl488100_upward_adjustm_cpe', 'ussgl490100_delivered_orde_fyb',
'ussgl490100_delivered_orde_cpe', 'ussgl498100_upward_adjustm_cpe',
'ussgl480200_undelivered_or_fyb', 'ussgl480200_undelivered_or_cpe',
'ussgl488200_upward_adjustm_cpe', 'ussgl490200_delivered_orde_cpe',
'ussgl490800_authority_outl_fyb', 'ussgl490800_authority_outl_cpe',
'ussgl498200_upward_adjustm_cpe']
for i in range(len(keys)):
op_dict_copy = copy.deepcopy(op_dict)
op_dict_copy.pop(keys[i])
op = ObjectClassProgramActivityFactory(**op_dict_copy)
assert number_of_errors(_FILE, database, models=[op]) == 1
op = ObjectClassProgramActivityFactory(by_direct_reimbursable_fun=None, object_class=123)
assert number_of_errors(_FILE, database, models=[op]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:28,代码来源:test_b12_object_class_program_activity_1.py
示例6: test_failure
def test_failure(database):
""" Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided and
by_direct_reimbursable_fun is empty the rule fails """
af_dict = {'by_direct_reimbursable_fun': None, 'ussgl480100_undelivered_or_fyb': None,
'ussgl480100_undelivered_or_cpe': None, 'ussgl488100_upward_adjustm_cpe': None,
'ussgl490100_delivered_orde_fyb': None, 'ussgl490100_delivered_orde_cpe': None,
'ussgl498100_upward_adjustm_cpe': None, 'ussgl480200_undelivered_or_fyb': None,
'ussgl480200_undelivered_or_cpe': None, 'ussgl488200_upward_adjustm_cpe': None,
'ussgl490200_delivered_orde_cpe': None, 'ussgl490800_authority_outl_fyb': None,
'ussgl490800_authority_outl_cpe': None, 'ussgl498200_upward_adjustm_cpe': None}
keys = ['ussgl480100_undelivered_or_fyb', 'ussgl480100_undelivered_or_cpe',
'ussgl488100_upward_adjustm_cpe', 'ussgl490100_delivered_orde_fyb',
'ussgl490100_delivered_orde_cpe', 'ussgl498100_upward_adjustm_cpe',
'ussgl480200_undelivered_or_fyb', 'ussgl480200_undelivered_or_cpe',
'ussgl488200_upward_adjustm_cpe', 'ussgl490200_delivered_orde_cpe',
'ussgl490800_authority_outl_fyb', 'ussgl490800_authority_outl_cpe',
'ussgl498200_upward_adjustm_cpe']
# Takes out one required key at a time and check that we get exactly one
# error
for i in range(len(keys)):
af_dict_copy = copy.deepcopy(af_dict)
af_dict_copy.pop(keys[i])
af = AwardFinancialFactory(**af_dict_copy)
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(by_direct_reimbursable_fun=None)
assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:30,代码来源:test_b12_award_financial_1.py
示例7: test_pubished_date_success
def test_pubished_date_success(database):
""" Test valid. For (ActionType = B, C, or D), the CFDA_Number need NOT be active as of the ActionDate.
Not apply to those with CorrectionDeleteIndicator = C.
Active date: publish_date <= action_date <= archive_date (Fails validation if active).
"""
cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140528',
action_type='B', correction_delete_indicatr="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140428',
action_type='C', correction_delete_indicatr="D")
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140428',
action_type='D', correction_delete_indicatr=None)
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
assert errors == 0
cfda = CFDAProgram(program_number=12.350, published_date="20130427", archived_date="20140427")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130528',
action_type='B', correction_delete_indicatr="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130428',
action_type='C', correction_delete_indicatr="D")
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130428',
action_type='D', correction_delete_indicatr=None)
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
assert errors == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_fabs37_detached_award_financial_assistance_2.py
示例8: test_pubished_date_failure
def test_pubished_date_failure(database):
""" Test invalid. For (ActionType = B, C, or D), the CFDA_Number need NOT be active as of the ActionDate.
Not apply to those with CorrectionLateDeleteIndicator = C.
Active date: publish_date <= action_date <= archive_date (Fails validation if active).
If action date is < published_date, should trigger a warning.
"""
cfda = CFDAProgram(program_number="12.345", published_date="20130427", archived_date="")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120528',
action_type='B', correction_late_delete_ind="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120427',
action_type='C', correction_late_delete_ind="D")
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120428',
action_type='D', correction_late_delete_ind=None)
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
assert errors == 3
cfda = CFDAProgram(program_number="12.345", published_date="20130427", archived_date="20140528")
det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120528',
action_type='B', correction_late_delete_ind="B")
det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20150427',
action_type='C', correction_late_delete_ind="D")
det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20150428',
action_type='D', correction_late_delete_ind=None)
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
assert errors == 3
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:26,代码来源:test_fabs37_detached_award_financial_assistance_2.py
示例9: test_success
def test_success(database):
""" Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided then
by_direct_reimbursable_fun is not empty """
op = ObjectClassProgramActivityFactory()
assert number_of_errors(_FILE, database, models=[op]) == 0
op = ObjectClassProgramActivityFactory(object_class=1234, by_direct_reimbursable_fun=None)
assert number_of_errors(_FILE, database, models=[op]) == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:9,代码来源:test_b12_object_class_program_activity_1.py
示例10: test_success
def test_success(database):
""" ObligationsDeliveredOrdersUnpaidTotal in File C = USSGL 4901 + 4981 in File C for the same date context
(FYB) """
af = AwardFinancialFactory(obligations_delivered_orde_fyb=None, ussgl490100_delivered_orde_fyb=None)
assert number_of_errors(_FILE, database, models=[af]) == 0
af = AwardFinancialFactory(obligations_delivered_orde_fyb=1, ussgl490100_delivered_orde_fyb=1)
assert number_of_errors(_FILE, database, models=[af]) == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:11,代码来源:test_c4_award_financial_2.py
示例11: test_failure
def test_failure(database):
""" ObligationsUndeliveredOrdersUnpaidTotal in File C != USSGL 4801 + 4881 in File C for the same date context
(FYB) """
af = AwardFinancialFactory(obligations_undelivered_or_fyb=1, ussgl480100_undelivered_or_fyb=None)
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(obligations_undelivered_or_fyb=1, ussgl480100_undelivered_or_fyb=2)
assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:11,代码来源:test_c3_award_financial_2.py
示例12: test_failure
def test_failure(database):
""" ObligationsDeliveredOrdersUnpaidTotal in File C != USSGL 4901 + 4981 in File C for the same date context
(CPE) """
af = AwardFinancialFactory(obligations_delivered_orde_cpe=1, ussgl490100_delivered_orde_cpe=None,
ussgl498100_upward_adjustm_cpe=None)
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(obligations_delivered_orde_cpe=1, ussgl490100_delivered_orde_cpe=1,
ussgl498100_upward_adjustm_cpe=1)
assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:13,代码来源:test_c4_award_financial_1.py
示例13: test_failure
def test_failure(database):
""" Unique PIID, ParentAwardId from file D1 doesn't exist in file C during the same reporting period,
except D1 records with zero FederalActionObligation """
ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_parent_award_id', federal_action_obligation=1)
af = AwardFinancialFactory(piid='some_other_piid', parent_award_id='some_parent_award_id')
assert number_of_errors(_FILE, database, models=[af, ap]) == 1
ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_parent_award_id', federal_action_obligation=1)
af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_other_parent_award_id')
assert number_of_errors(_FILE, database, models=[af, ap]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:13,代码来源:test_c12_cross_file.py
示例14: test_failure
def test_failure(database):
""" DeobligationsRecoveriesRefundsOfPriorYearByProgramObjectClass_CPE in File B != USSGL(4871+ 4872 + 4971 + 4972)
in File B for the same reporting period """
op = ObjectClassProgramActivityFactory(deobligations_recov_by_pro_cpe=1, ussgl487100_downward_adjus_cpe=None,
ussgl487200_downward_adjus_cpe=None, ussgl497100_downward_adjus_cpe=None,
ussgl497200_downward_adjus_cpe=None)
assert number_of_errors(_FILE, database, models=[op]) == 1
op = ObjectClassProgramActivityFactory(deobligations_recov_by_pro_cpe=1, ussgl487100_downward_adjus_cpe=1,
ussgl487200_downward_adjus_cpe=1, ussgl497100_downward_adjus_cpe=1,
ussgl497200_downward_adjus_cpe=1)
assert number_of_errors(_FILE, database, models=[op]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:15,代码来源:test_b13_object_class_program_activity.py
示例15: test_failure
def test_failure(database):
""" Test invalid object class code (3 digits) """
# This should return because if it's '0000' '000', '00', '0' a warning should be returned
af = AwardFinancialFactory(object_class='0000')
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(object_class='000')
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(object_class='00')
assert number_of_errors(_FILE, database, models=[af]) == 1
af = AwardFinancialFactory(object_class='0')
assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:15,代码来源:test_b11_award_financial_2.py
示例16: test_failure
def test_failure(database):
""" Test invalid object class code (3 digits) """
# This should return because if it's '0000' '000', '00', '0' a warning should be returned
op = ObjectClassProgramActivityFactory(object_class='0000')
assert number_of_errors(_FILE, database, models=[op]) == 1
op = ObjectClassProgramActivityFactory(object_class='000')
assert number_of_errors(_FILE, database, models=[op]) == 1
op = ObjectClassProgramActivityFactory(object_class='00')
assert number_of_errors(_FILE, database, models=[op]) == 1
op = ObjectClassProgramActivityFactory(object_class='0')
assert number_of_errors(_FILE, database, models=[op]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:15,代码来源:test_b11_object_class_program_activity_2.py
示例17: test_success
def test_success(database):
""" The provided PrimaryPlaceofPerformanceZIP+4 must be in the state specified by PrimaryPlaceOfPerformanceCode.
In this specific submission row, the first five digits are valid and located in the correct state, but the
last 4 are invalid."""
zips = Zips(zip5="12345", zip_last4="6789", state_abbreviation="NY")
# ignored because no zip4
det_award_1 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY*****",
place_of_performance_zip4a="")
det_award_2 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Ny**123",
place_of_performance_zip4a=None)
det_award_3 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Ny**123",
place_of_performance_zip4a='city-wide')
# valid 9 digit zip
det_award_4 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY98765",
place_of_performance_zip4a="123456789")
det_award_5 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny98765",
place_of_performance_zip4a="123456789")
det_award_6 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny98765",
place_of_performance_zip4a="12345-6789")
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, det_award_5,
det_award_6, zips])
assert errors == 0
# random wrong length zips and zips with '-' in the wrong place, formatting is checked in another rule
det_award_1 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10986",
place_of_performance_zip4a="12345678")
det_award_2 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10986",
place_of_performance_zip4a="1234567898")
det_award_3 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10986",
place_of_performance_zip4a="12345678-9")
det_award_4 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10986",
place_of_performance_zip4a="123-456789")
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, zips])
assert errors == 0
# invalid 5 digit zip - this should pass but is handled in d41_3
det_award_1 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10986",
place_of_performance_zip4a="12346")
det_award_2 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NA*****",
place_of_performance_zip4a='12345')
det_award_3 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NA*****",
place_of_performance_zip4a='12346-6789')
# valid 5 digit zip
det_award_4 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Ny**123",
place_of_performance_zip4a="12345")
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, zips])
assert errors == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:48,代码来源:test_fabs41_detached_award_financial_assistance_5.py
示例18: test_failure
def test_failure(database):
""" Test failure for each unique PIID in File C, the sum of each TransactionObligatedAmount should match (but with
opposite signs) the sum of the FederalActionObligation reported in D1. This rule does not apply if the ATA field
is populated and is different from the Agency ID. Ignore rows that contain a PAID. """
# Create a 12 character random piid
piid_1 = ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for _ in range(12))
piid_2 = ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for _ in range(12))
piid_3 = ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for _ in range(12))
# No ATA, not matching (off by 1)
af_1_row_1 = AwardFinancialFactory(transaction_obligated_amou=1100, piid=piid_1, parent_award_id='',
allocation_transfer_agency=None)
af_1_row_2 = AwardFinancialFactory(transaction_obligated_amou=11, piid=piid_1, parent_award_id=None,
allocation_transfer_agency=None)
# No ATA, not matching, one record, no paid
af_2 = AwardFinancialFactory(transaction_obligated_amou=9999, piid=piid_2, parent_award_id=None,
allocation_transfer_agency=None)
# Matching ATA, should not be ignored
af_3 = AwardFinancialFactory(transaction_obligated_amou=11, piid=piid_3, parent_award_id=None,
allocation_transfer_agency="123", agency_identifier="123")
# Award Procurement portion of checks
# Sum of all these would be sum of piid_1 af if one wasn't ignored
ap_1_row_1 = AwardProcurementFactory(piid=piid_1, parent_award_id=None, federal_action_obligation=-1100)
ap_1_row_2 = AwardProcurementFactory(piid=piid_1, parent_award_id=None, federal_action_obligation=-10)
# second piid that simply doesn't match
ap_2 = AwardProcurementFactory(piid=piid_2, parent_award_id=None, federal_action_obligation=-1111)
# third piid that should not be ignored because ATA is present but matches
ap_3 = AwardProcurementFactory(piid=piid_3, parent_award_id=None, federal_action_obligation=0)
errors = number_of_errors(_FILE, database, models=[af_1_row_1, af_1_row_2, af_2, af_3, ap_1_row_1, ap_1_row_2, ap_2,
ap_3])
assert errors == 3
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:35,代码来源:test_c23_award_financial_1.py
示例19: test_success
def test_success(database):
""" For PrimaryPlaceOfPerformanceCode XX##### city must exist in provided state (zip4 provided, warning).
Ignore for all other formats of PrimaryPlaceOfPerformanceCode """
# XX00000 validates here because it passes as long as the zip is valid in that state, this is checked
# in a different place
city_code = CityCode(city_code="10987", state_code="NY")
det_award_1 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY*****",
place_of_performance_zip4a="2")
det_award_2 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY**123",
place_of_performance_zip4a="1")
det_award_3 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY**123",
place_of_performance_zip4a=None)
det_award_4 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="ny10987",
place_of_performance_zip4a="12345")
det_award_5 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="NY10987",
place_of_performance_zip4a="12345-6789")
det_award_6 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Na10987",
place_of_performance_zip4a=None)
det_award_7 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Ny10988",
place_of_performance_zip4a='')
det_award_8 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="nY000000",
place_of_performance_zip4a='12345')
det_award_9 = DetachedAwardFinancialAssistanceFactory(place_of_performance_code="Ny10988",
place_of_performance_zip4a='city-wide')
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, det_award_5,
det_award_6, det_award_7, det_award_8, det_award_9, city_code])
assert errors == 0
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:28,代码来源:test_fabs41_detached_award_financial_assistance_2.py
示例20: test_success
def test_success(database):
""" AwardeeOrRecipientUniqueIdentifier Field must be blank for aggregate records (RecordType=1)
and individual recipients (BusinessTypes includes 'P'). """
det_award_1 = DetachedAwardFinancialAssistanceFactory(record_type=1, business_types="ABP",
awardee_or_recipient_uniqu='')
det_award_2 = DetachedAwardFinancialAssistanceFactory(record_type=1, business_types="ABC",
awardee_or_recipient_uniqu=None)
det_award_3 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="pbc",
awardee_or_recipient_uniqu=None)
det_award_4 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="PBC",
awardee_or_recipient_uniqu='')
det_award_5 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="apc",
awardee_or_recipient_uniqu='')
det_award_6 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="APC",
awardee_or_recipient_uniqu=None)
det_award_7 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="abp",
awardee_or_recipient_uniqu='')
det_award_8 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="ABP",
awardee_or_recipient_uniqu=None)
det_award_9 = DetachedAwardFinancialAssistanceFactory(record_type=2, business_types="ABC",
awardee_or_recipient_uniqu='test')
errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, det_award_5,
det_award_6, det_award_7, det_award_8, det_award_9])
assert errors == 0
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_fabs31_detached_award_financial_assistance_1.py
注:本文中的tests.unit.dataactvalidator.utils.number_of_errors函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论