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 CorrectionDeleteIndicator = 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.340, published_date='20130427', archived_date='') det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.340', action_date='20120528', action_type='b', correction_delete_indicatr='B') det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.340', action_date='20120427', action_type='C', correction_delete_indicatr='') det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.340', action_date='20120428', 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 == 3 cfda = CFDAProgram(program_number=12.350, published_date='20130427', archived_date='20140528') det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.350', action_date='20120528', action_type='B', correction_delete_indicatr='B') det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.350', action_date='20150427', action_type='c', correction_delete_indicatr='') det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number='12.350', action_date='20150428', 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 == 3
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='') fabs_1 = FABSFactory(cfda_number='12.340', action_date='20140528', action_type='b', correction_delete_indicatr='B') fabs_2 = FABSFactory(cfda_number='12.340', action_date='20140428', action_type='c', correction_delete_indicatr='') fabs_3 = FABSFactory(cfda_number='12.340', action_date='20140428', action_type='D', correction_delete_indicatr=None) # Ignore correction delete indicator of D fabs_4 = FABSFactory(cfda_number='12.340', action_date='20120528', action_type='B', correction_delete_indicatr='d') errors = number_of_errors(_FILE, database, models=[fabs_1, fabs_2, fabs_3, fabs_4, cfda]) assert errors == 0 cfda = CFDAProgram(program_number=12.350, published_date='20130427', archived_date='20140427') fabs_1 = FABSFactory(cfda_number='12.350', action_date='20130528', action_type='b', correction_delete_indicatr='B') fabs_2 = FABSFactory(cfda_number='12.350', action_date='20130428', action_type='C', correction_delete_indicatr='') fabs_3 = FABSFactory(cfda_number='12.350', action_date='20130428', action_type='d', correction_delete_indicatr=None) errors = number_of_errors(_FILE, database, models=[fabs_1, fabs_2, fabs_3, cfda]) assert errors == 0
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.340, published_date="20130427", archived_date="20140427") det_award_1 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", action_date='20130528', action_type='B', correction_delete_indicatr="B") det_award_2 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", action_date='20130428', action_type='C', correction_delete_indicatr="D") det_award_3 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", 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
def test_failure(database): """ Test invalid. For ActionType = A, the CFDA_Number must be active as of the ActionDate. Not apply to those with CorrectionDeleteIndicator = 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_delete_indicatr="B") det_award_2 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", action_date='20120111', action_type='A', correction_delete_indicatr=None) det_award_3 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", action_date='20120111', action_type='A', correction_delete_indicatr="B") det_award_4 = DetachedAwardFinancialAssistanceFactory( cfda_number="12.340", action_date='20120111', action_type='A', correction_delete_indicatr=None) errors = number_of_errors( _FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, cfda]) assert errors == 4
def test_failure(database): """ Test invalid. For new (ActionType = A) or mixed aggregate (ActionType = E) assistance awards specifically, the CFDA_Number must be active as of the ActionDate. This does not apply to correction records (those with CorrectionDeleteIndicator = C and delete records). """ cfda = CFDAProgram(program_number=12.340, published_date='20130427', archived_date='') fabs_1 = FABSFactory(cfda_number='12.340', action_date='20120111', action_type='e', correction_delete_indicatr='B') fabs_2 = FABSFactory(cfda_number='12.340', action_date='20120111', action_type='A', correction_delete_indicatr=None) fabs_3 = FABSFactory(cfda_number='12.340', action_date='20120111', action_type='a', correction_delete_indicatr='B') fabs_4 = FABSFactory(cfda_number='12.340', action_date='20120111', action_type='E', correction_delete_indicatr=None) errors = number_of_errors(_FILE, database, models=[fabs_1, fabs_2, fabs_3, fabs_4, cfda]) assert errors == 4
def test_success(database): """ Test that no errors occur when the cfda_number exists. """ cfda = CFDAProgram(program_number=12.340) det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340") errors = number_of_errors(_FILE, database, models=[det_award_1, cfda]) assert errors == 0
def test_success(database): """ Test that no errors occur when the cfda_number exists. """ cfda = CFDAProgram(program_number=12.340) fabs_1 = FABSFactory(cfda_number='12.340', correction_delete_indicatr='') # Ignore correction delete indicator of D fabs_2 = FABSFactory(cfda_number='AB.CDE', correction_delete_indicatr='d') errors = number_of_errors(_FILE, database, models=[fabs_1, fabs_2, cfda]) assert errors == 0
def test_failure(database): """ Test that its fails when cfda_number does not exists. """ # test for cfda_number that doesn't exist in the table cfda = CFDAProgram(program_number=12.340) det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="54.321") det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="AB.CDE") det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="11.111") errors = number_of_errors( _FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda]) assert errors == 3
def test_failure(database): """ Test that its fails when cfda_number does not exists. """ # test for cfda_number that doesn't exist in the table cfda = CFDAProgram(program_number=12.340) fabs_1 = FABSFactory(cfda_number='54.321', correction_delete_indicatr='') fabs_2 = FABSFactory(cfda_number='AB.CDE', correction_delete_indicatr='c') fabs_3 = FABSFactory(cfda_number='11.111', correction_delete_indicatr=None) errors = number_of_errors(_FILE, database, models=[fabs_1, fabs_2, fabs_3, cfda]) assert errors == 3
def test_success(database): """ Test that no errors occur when the cfda_number exists. """ cfda = CFDAProgram(program_number=12.340) det_award_1 = DetachedAwardFinancialAssistanceFactory( cfda_number='12.340', correction_delete_indicatr='') # Ignore correction delete indicator of D det_award_2 = DetachedAwardFinancialAssistanceFactory( cfda_number='AB.CDE', correction_delete_indicatr='d') errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, cfda]) assert errors == 0
def test_success(database): """ Test valid. For ActionType = A, the CFDA_Number must be active as of the ActionDate. Not apply to those with CorrectionDeleteIndicator = C. If publish_date <= action_date <= archived_date, it passes validation (active). """ cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="") det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140111', action_type='A', correction_delete_indicatr="B") det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140111', action_type='A', correction_delete_indicatr=None) det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20130427', action_type='A', correction_delete_indicatr="B") det_award_4 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20110111', action_type='B', correction_delete_indicatr="B") det_award_5 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20110111', action_type='A', correction_delete_indicatr="C") errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, det_award_5, cfda]) assert errors == 0 cfda = CFDAProgram(program_number=12.350, published_date="20130427", archived_date="20150427") det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20140111', action_type='A', correction_delete_indicatr="B") det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20140111', action_type='A', correction_delete_indicatr=None) det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130427', action_type='A', correction_delete_indicatr="B") det_award_4 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20110111', action_type='B', correction_delete_indicatr="B") det_award_5 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20110111', action_type='A', correction_delete_indicatr="C") errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, det_award_5, cfda]) assert errors == 0
def test_failure(database): """ Test that its fails when cfda_number does not exists. """ # test for cfda_number that doesn't exist in the table cfda = CFDAProgram(program_number=12.340) det_award_1 = DetachedAwardFinancialAssistanceFactory( cfda_number='54.321', correction_delete_indicatr='') det_award_2 = DetachedAwardFinancialAssistanceFactory( cfda_number='AB.CDE', correction_delete_indicatr='c') det_award_3 = DetachedAwardFinancialAssistanceFactory( cfda_number='11.111', correction_delete_indicatr=None) errors = number_of_errors( _FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda]) assert errors == 3