def test_failure_pa_code_0000(database):
    """ Failure where the program_activity_code is 0000 but program_activity_name isn't unknown/other """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1,
                               submission_id=1,
                               agency_identifier='test',
                               main_account_code='test',
                               program_activity_name='test',
                               program_activity_code='0000')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q4',
                                agency_id='test',
                                allocation_transfer_id='test',
                                account_number='test',
                                program_activity_name='test',
                                program_activity_code='test')

    submission = SubmissionFactory(
        submission_id=1,
        reporting_fiscal_year='2016',
        reporting_fiscal_period=12,
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE,
                            database,
                            models=[af, pa],
                            submission=submission) == 1
def test_failure_fiscal_year_quarter(database):
    """ Testing invalid program activity, does not match with fiscal_year_quarter """

    populate_publish_status(database)

    op = ObjectClassProgramActivityFactory(row_number=1,
                                           submission_id=1,
                                           agency_identifier='test2',
                                           main_account_code='test2',
                                           program_activity_name='test2',
                                           program_activity_code='test2')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY15Q1',
                                agency_id='test',
                                allocation_transfer_id='test',
                                account_number='test',
                                program_activity_name='test',
                                program_activity_code='test')

    submission = SubmissionFactory(
        submission_id=1,
        reporting_fiscal_year='2018',
        reporting_fiscal_period=9,
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE,
                            database,
                            models=[op, pa],
                            submission=submission) == 1
def test_success_fiscal_year_quarter(database):
    """ Testing valid name for program_activity that matches with fiscal_year_quarter """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1,
                               submission_id=1,
                               agency_identifier='test',
                               main_account_code='test',
                               program_activity_name='test',
                               program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q1',
                                agency_id='test',
                                allocation_transfer_id='test',
                                account_number='test',
                                program_activity_name='test',
                                program_activity_code='test')

    submission = SubmissionFactory(
        submission_id=1,
        reporting_fiscal_year='2016',
        reporting_fiscal_period=3,
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE,
                            database,
                            models=[af, pa],
                            submission=submission) == 0
def test_failure_success_ignore_recertification(database):
    """ Testing invalid program activity, ingored since FY2017 Q2 or Q3 """

    populate_publish_status(database)

    populate_publish_status(database)

    op = ObjectClassProgramActivityFactory(row_number=1, submission_id=1, agency_identifier='test2',
                                           main_account_code='test2', program_activity_name='test2',
                                           program_activity_code='test2')

    pa = ProgramActivityFactory(fiscal_year_period='FY14P03', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    # Test with published submission
    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2017', reporting_fiscal_period=6,
                                   publish_status_id=PUBLISH_STATUS_DICT['updated'])

    assert number_of_errors(_FILE, database, models=[op, pa], submission=submission) == 0

    # Test with unpublished submission
    submission = SubmissionFactory(submission_id=2, reporting_fiscal_year='2017', reporting_fiscal_period=6,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[op, pa], submission=submission) == 0
def test_success_ignore_case(database):
    """ Testing program activity validation to ignore case """

    populate_publish_status(database)

    op = ObjectClassProgramActivityFactory(row_number=1,
                                           submission_id=1,
                                           beginning_period_of_availa=2016,
                                           agency_identifier='test',
                                           main_account_code='test',
                                           program_activity_name='TEST',
                                           program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q4',
                                agency_id='test',
                                allocation_transfer_id='test',
                                account_number='test',
                                program_activity_name='test',
                                program_activity_code='test')

    submission = SubmissionFactory(
        submission_id=1,
        reporting_fiscal_year='2017',
        reporting_fiscal_period=12,
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE,
                            database,
                            models=[op, pa],
                            submission=submission) == 0
Exemplo n.º 6
0
def test_failure_recertification(database):
    """ Testing invalid program_activity, not ignored since not recertification for FY2017Q2 or FY2017Q3 """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1,
                               submission_id=1,
                               agency_identifier='test',
                               main_account_code='test',
                               program_activity_name='test',
                               program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q3',
                                agency_id='test2',
                                allocation_transfer_id='test2',
                                account_number='test2',
                                program_activity_name='test2',
                                program_activity_code='test2')

    submission = SubmissionFactory(
        submission_id=1,
        reporting_fiscal_year='2017',
        reporting_fiscal_period=9,
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE,
                            database,
                            models=[af, pa],
                            submission=submission) == 1
def test_value_present(database):
    """budget_authority_unobligat_fyb populated does not require a previous submission"""
    populate_publish_status(database)
    sub_new = SubmissionFactory()
    ap_new = AppropriationFactory(submission_id=sub_new.submission_id)
    assert number_of_errors(_FILE,
                            database,
                            submission=sub_new,
                            models=[ap_new]) == 0
def test_no_previous_submission(database):
    """ No previous submission and null budget_authority_unobligat_fyb"""
    populate_publish_status(database)
    sub_new = SubmissionFactory()
    ap_new = AppropriationFactory(submission_id=sub_new.submission_id,
                                  budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE,
                            database,
                            submission=sub_new,
                            models=[ap_new]) == 1
def test_previous_published(database):
    """ budget_authority_unobligat_fyb can be null if previous published submission shares cgac and fiscal year """
    populate_publish_status(database)
    sub_prev_published = SubmissionFactory(publish_status_id=PUBLISH_STATUS_DICT['published'])
    insert_submission(database, sub_prev_published)
    sub_new_published = SubmissionFactory(cgac_code=sub_prev_published.cgac_code,
                                          reporting_fiscal_year=sub_prev_published.reporting_fiscal_year)
    ap_new_published = AppropriationFactory(submission_id=sub_new_published.submission_id,
                                            budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE, database, submission=sub_new_published,
                            models=[ap_new_published]) == 0
def test_previous_publishable(database):
    """Previous submission marked as publishable also allows null"""
    populate_publish_status(database)
    sub_prev_publishable = SubmissionFactory(publishable=True)
    insert_submission(database, sub_prev_publishable)
    sub_new_publishable = SubmissionFactory(cgac_code=sub_prev_publishable.cgac_code,
                                            reporting_fiscal_year=sub_prev_publishable.reporting_fiscal_year)
    ap_new_publishable = AppropriationFactory(submission_id=sub_new_publishable.submission_id,
                                              budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE, database, submission=sub_new_publishable,
                            models=[ap_new_publishable]) == 0
def test_previous_unpublished(database):
    """ previous submission exists but is unpublished and has not been marked publishable """
    populate_publish_status(database)
    sub_prev_published = SubmissionFactory(publish_status_id=PUBLISH_STATUS_DICT['unpublished'], publishable=False)
    insert_submission(database, sub_prev_published)
    sub_new_published = SubmissionFactory(cgac_code=sub_prev_published.cgac_code,
                                          reporting_fiscal_year=sub_prev_published.reporting_fiscal_year)
    ap_new_published = AppropriationFactory(submission_id=sub_new_published.submission_id,
                                            budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE, database, submission=sub_new_published,
                            models=[ap_new_published]) == 1
def test_success_null(database):
    """ Program activity name/code as null """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, agency_identifier='test', main_account_code='test',
                               program_activity_name=None, program_activity_code=None)

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q4', agency_id='test', allocation_transfer_id='test',
                                account_number='test')

    assert number_of_errors(_FILE, database, models=[af, pa]) == 0
def test_success_null(database):
    """ Program activity name/code as null """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, agency_identifier='test', main_account_code='test',
                               program_activity_name=None, program_activity_code=None)

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q4', agency_id='test', allocation_transfer_id='test',
                                account_number='test')

    assert number_of_errors(_FILE, database, models=[af, pa]) == 0
def test_previous_publishable(database):
    """Previous submission marked as publishable also allows null"""
    populate_publish_status(database)
    sub_prev_publishable = SubmissionFactory(publishable=True)
    insert_submission(database, sub_prev_publishable)
    sub_new_publishable = SubmissionFactory(
        cgac_code=sub_prev_publishable.cgac_code,
        reporting_fiscal_year=sub_prev_publishable.reporting_fiscal_year)
    ap_new_publishable = AppropriationFactory(
        submission_id=sub_new_publishable.submission_id,
        budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE,
                            database,
                            submission=sub_new_publishable,
                            models=[ap_new_publishable]) == 0
def test_success_fiscal_year_quarter(database):
    """ Testing valid name for program_activity that matches with fiscal_year_quarter """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                               main_account_code='test', program_activity_name='test', program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q1', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=3,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af, pa], submission=submission) == 0
Exemplo n.º 16
0
def test_success_ignore_case(database):
    """ Testing program activity validation to ignore case """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test', main_account_code='test',
                               program_activity_name='TEST', program_activity_code='TEST')

    pa = ProgramActivityFactory(fiscal_year_period='FY16P12', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=12,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af, pa], submission=submission) == 0
def test_previous_published(database):
    """ budget_authority_unobligat_fyb can be null if previous published submission shares cgac and fiscal year """
    populate_publish_status(database)
    sub_prev_published = SubmissionFactory(
        publish_status_id=PUBLISH_STATUS_DICT['published'])
    insert_submission(database, sub_prev_published)
    sub_new_published = SubmissionFactory(
        cgac_code=sub_prev_published.cgac_code,
        reporting_fiscal_year=sub_prev_published.reporting_fiscal_year)
    ap_new_published = AppropriationFactory(
        submission_id=sub_new_published.submission_id,
        budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE,
                            database,
                            submission=sub_new_published,
                            models=[ap_new_published]) == 0
def test_failure_pa_code_0000(database):
    """ Failure where the program_activity_code is 0000 but program_activity_name isn't unknown/other """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                               main_account_code='test', program_activity_name='test',
                               program_activity_code='0000')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q4', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=12,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af, pa], submission=submission) == 1
def test_previous_unpublished(database):
    """ previous submission exists but is unpublished and has not been marked publishable """
    populate_publish_status(database)
    sub_prev_published = SubmissionFactory(
        publish_status_id=PUBLISH_STATUS_DICT['unpublished'],
        publishable=False)
    insert_submission(database, sub_prev_published)
    sub_new_published = SubmissionFactory(
        cgac_code=sub_prev_published.cgac_code,
        reporting_fiscal_year=sub_prev_published.reporting_fiscal_year)
    ap_new_published = AppropriationFactory(
        submission_id=sub_new_published.submission_id,
        budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE,
                            database,
                            submission=sub_new_published,
                            models=[ap_new_published]) == 1
Exemplo n.º 20
0
def test_failure_fiscal_year_period(database):
    """ Testing invalid program_activity, does not match with fiscal_year_period """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                               main_account_code='test', program_activity_name='test',
                               program_activity_code='test')

    pa_1 = ProgramActivityFactory(fiscal_year_period='FPY', agency_id='test', allocation_transfer_id='test',
                                  account_number='test', program_activity_name='test', program_activity_code='test')

    pa_2 = ProgramActivityFactory(fiscal_year_period='FY16P03', agency_id='test2', allocation_transfer_id='test2',
                                  account_number='test2', program_activity_name='test2', program_activity_code='test2')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=3,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af, pa_1, pa_2], submission=submission) == 1
Exemplo n.º 21
0
def test_failure_program_activity_code(database):
    """ Failure where the program_activity_code does not match """

    populate_publish_status(database)

    af_1 = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                                 main_account_code='test', program_activity_name='test',
                                 program_activity_code='test_wrong')

    af_2 = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test', main_account_code='test',
                                 program_activity_name='Unknown/Other', program_activity_code='12345')

    pa = ProgramActivityFactory(fiscal_year_period='FY16P12', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=12,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af_1, af_2, pa], submission=submission) == 2
def test_failure_program_activity_name(database):
    """ Testing invalid program activity name for the corresponding TAS/TAFS as defined in Section 82 of OMB Circular
    A-11. """

    populate_publish_status(database)

    op_1 = ObjectClassProgramActivityFactory(row_number=1, agency_identifier='test', main_account_code='test',
                                             program_activity_name='test_wrong', program_activity_code='test')

    op_2 = ObjectClassProgramActivityFactory(row_number=1, agency_identifier='test', main_account_code='test',
                                             program_activity_name='test_wrong', program_activity_code='0000')

    pa = ProgramActivityFactory(fiscal_year_period='FY17P03', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2017', reporting_fiscal_period=3,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[op_1, op_2, pa], submission=submission) == 2
def test_success_ignore_pa_code_0000_pa_name_unknown_other(database):
    """ Test that rule is ignored when program_activity_code is 0000 AND program_activity_name is unknown/other """

    populate_publish_status(database)

    af_1 = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                                 main_account_code='test', program_activity_name='Unknown/Other',
                                 program_activity_code='0000')

    # Ignore case
    af_2 = AwardFinancialFactory(row_number=2, submission_id=1, agency_identifier='test', main_account_code='test',
                                 program_activity_name='UnKnown/OthEr', program_activity_code='0000')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q4', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=12,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af_1, af_2, pa], submission=submission) == 0
def test_success(database):
    """ Testing valid program activity name for the corresponding TAS/TAFS as defined in Section 82 of OMB Circular
         A-11.
    """

    populate_publish_status(database)

    af_1 = AwardFinancialFactory(row_number=1, agency_identifier='test', submission_id=1, main_account_code='test',
                                 program_activity_name='test', program_activity_code='test')

    af_2 = AwardFinancialFactory(row_number=2, agency_identifier='test', submission_id=1,  main_account_code='test',
                                 program_activity_name='test', program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q1', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2017', reporting_fiscal_period=3,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af_1, af_2, pa], submission=submission) == 0
def test_success_ignore_pa_code_0000_pa_name_unknown_other(database):
    """ Test that rule is ignored when program_activity_code is 0000 AND program_activity_name is unknown/other """

    populate_publish_status(database)

    af_1 = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                                 main_account_code='test', program_activity_name='Unknown/Other',
                                 program_activity_code='0000')

    # Ignore case
    af_2 = AwardFinancialFactory(row_number=2, submission_id=1, agency_identifier='test', main_account_code='test',
                                 program_activity_name='UnKnown/OthEr', program_activity_code='0000')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY16Q4', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2016', reporting_fiscal_period=12,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af_1, af_2, pa], submission=submission) == 0
def test_success(database):
    """ Testing valid program activity name for the corresponding TAS/TAFS as defined in Section 82 of OMB Circular
         A-11.
    """

    populate_publish_status(database)

    af_1 = AwardFinancialFactory(row_number=1, agency_identifier='test', submission_id=1, main_account_code='test',
                                 program_activity_name='test', program_activity_code='test')

    af_2 = AwardFinancialFactory(row_number=2, agency_identifier='test', submission_id=1,  main_account_code='test',
                                 program_activity_name='test', program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q1', agency_id='test', allocation_transfer_id='test',
                                account_number='test', program_activity_name='test', program_activity_code='test')

    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2017', reporting_fiscal_period=3,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af_1, af_2, pa], submission=submission) == 0
def test_success_ignore_old_fy2017(database):
    """ Testing invalid program_activity, ignored since FY2017Q2 or FY2017Q3 """

    populate_publish_status(database)

    af = AwardFinancialFactory(row_number=1, submission_id=1, agency_identifier='test',
                               main_account_code='test', program_activity_name='test', program_activity_code='test')

    pa = ProgramActivityFactory(fiscal_year_quarter='FY17Q3', agency_id='test2', allocation_transfer_id='test2',
                                account_number='test2', program_activity_name='test2', program_activity_code='test2')

    # Test with published submission
    submission = SubmissionFactory(submission_id=1, reporting_fiscal_year='2017', reporting_fiscal_period=9,
                                   publish_status_id=PUBLISH_STATUS_DICT['published'])

    assert number_of_errors(_FILE, database, models=[af, pa], submission=submission) == 0

    # Test with unpublished submission
    submission = SubmissionFactory(submission_id=2, reporting_fiscal_year='2017', reporting_fiscal_period=9,
                                   publish_status_id=PUBLISH_STATUS_DICT['unpublished'])

    assert number_of_errors(_FILE, database, models=[af, pa], submission=submission) == 0
def test_no_previous_submission(database):
    """ No previous submission and null budget_authority_unobligat_fyb"""
    populate_publish_status(database)
    sub_new = SubmissionFactory()
    ap_new = AppropriationFactory(submission_id=sub_new.submission_id, budget_authority_unobligat_fyb=None)
    assert number_of_errors(_FILE, database, submission=sub_new, models=[ap_new]) == 1
Exemplo n.º 29
0
def test_failure(database):
    """
        Test fail File C GrossOutlayAmountByAward_CPE balance for a TAS, DEFC, program activity code + name, object
        class code, direct/reimbursable flag, and Award ID combination should continue to be reported in subsequent
        periods during the FY, once it has been submitted to DATA Act, unless the most recently reported outlay balance
        for this award breakdown was zero. This only applies to File C outlays, not TOA.
    """
    populate_publish_status(database)
    # Base submission
    sub_1 = SubmissionFactory(
        submission_id=1,
        cgac_code='test',
        reporting_fiscal_year=2020,
        reporting_fiscal_period=3,
        frec_code=None,
        publish_status_id=PUBLISH_STATUS_DICT['published'],
        is_fabs=False)
    paf_fain = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='abcd',
        uri=None,
        piid=None,
        parent_award_id=None,
        disaster_emergency_fund_code='N',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_defc = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='abcd',
        uri=None,
        piid=None,
        parent_award_id='testingHere',
        disaster_emergency_fund_code='O',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_defc_9 = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='abcd',
        uri=None,
        piid=None,
        parent_award_id='testingHere',
        disaster_emergency_fund_code='9',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        gross_outlay_amount_by_awa_cpe=5)
    database.session.add_all([sub_1, paf_fain, paf_defc, paf_defc_9])
    database.session.commit()

    # submission missing previous period value, missing value of 9 still registers an error
    sub_2 = SubmissionFactory(submission_id=2,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=4,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=False,
                              is_fabs=False)

    errors = number_of_errors(_FILE, database, models=[], submission=sub_2)
    assert errors == 3

    # submission with a row that has similar but not exact values (has a uri when the original didn't)
    sub_3 = SubmissionFactory(submission_id=3,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=4,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=False,
                              is_fabs=False)
    af_other = AwardFinancialFactory(submission_id=sub_3.submission_id,
                                     tas='test_tas',
                                     fain='abcd',
                                     uri='efgh',
                                     piid=None,
                                     parent_award_id=None,
                                     disaster_emergency_fund_code='n',
                                     program_activity_code=None,
                                     program_activity_name=None,
                                     object_class=None,
                                     by_direct_reimbursable_fun=None,
                                     gross_outlay_amount_by_awa_cpe=5)
    af_defc = AwardFinancialFactory(submission_id=sub_3.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id='testingHere',
                                    disaster_emergency_fund_code='O',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=5)
    af_defc_9 = AwardFinancialFactory(submission_id=sub_3.submission_id,
                                      tas='test_tas',
                                      fain='abcd',
                                      uri=None,
                                      piid=None,
                                      parent_award_id='testingHere',
                                      disaster_emergency_fund_code='9',
                                      program_activity_code=None,
                                      program_activity_name=None,
                                      object_class=None,
                                      by_direct_reimbursable_fun=None,
                                      gross_outlay_amount_by_awa_cpe=5)

    errors = number_of_errors(_FILE,
                              database,
                              models=[af_other, af_defc, af_defc_9],
                              submission=sub_3)
    assert errors == 2

    # submission with a row that matches but has gross outlay of NULL
    sub_4 = SubmissionFactory(submission_id=4,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=4,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=False,
                              is_fabs=False)
    af_null = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=None)
    af_defc_9 = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                      tas='test_tas',
                                      fain='abcd',
                                      uri=None,
                                      piid=None,
                                      parent_award_id='testingHere',
                                      disaster_emergency_fund_code='n',
                                      program_activity_code=None,
                                      program_activity_name=None,
                                      object_class=None,
                                      by_direct_reimbursable_fun=None,
                                      gross_outlay_amount_by_awa_cpe=5)
    af_defc = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id='testingHere',
                                    disaster_emergency_fund_code='o',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=5)

    errors = number_of_errors(_FILE,
                              database,
                              models=[af_null, af_defc, af_defc_9],
                              submission=sub_4)
    assert errors == 2
Exemplo n.º 30
0
def test_success(database):
    """
        Test File C GrossOutlayAmountByAward_CPE balance for a TAS, DEFC, program activity code + name, object class
        code, direct/reimbursable flag, and Award ID combination should continue to be reported in subsequent periods
        during the FY, once it has been submitted to DATA Act, unless the most recently reported outlay balance for this
        award breakdown was zero. This only applies to File C outlays, not TOA.
    """
    populate_publish_status(database)
    # Base submission
    sub_1 = SubmissionFactory(
        submission_id=1,
        cgac_code='test',
        reporting_fiscal_year=2020,
        reporting_fiscal_period=3,
        frec_code=None,
        publish_status_id=PUBLISH_STATUS_DICT['published'],
        is_fabs=False)
    paf_fain = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='aBcD',
        uri=None,
        piid=None,
        parent_award_id=None,
        disaster_emergency_fund_code='N',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_uri = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                             tas='test_tas',
                                             fain=None,
                                             uri='eFgH',
                                             piid=None,
                                             parent_award_id=None,
                                             disaster_emergency_fund_code='n',
                                             program_activity_code=None,
                                             program_activity_name=None,
                                             object_class=None,
                                             by_direct_reimbursable_fun=None,
                                             gross_outlay_amount_by_awa_cpe=5)
    paf_piid = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain=None,
        uri=None,
        piid='iJkL',
        parent_award_id=None,
        disaster_emergency_fund_code='n',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_paid = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_TAS',
        fain=None,
        uri=None,
        piid='mNoP',
        parent_award_id='qRsT',
        disaster_emergency_fund_code='N',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_zero = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='xYz',
        uri=None,
        piid=None,
        parent_award_id=None,
        disaster_emergency_fund_code='n',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=0)
    paf_null = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='xyZ',
        uri=None,
        piid=None,
        parent_award_id=None,
        disaster_emergency_fund_code='n',
        program_activity_code=None,
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=None)
    paf_tas = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                             tas='different_tas',
                                             fain='hiJK',
                                             uri=None,
                                             piid=None,
                                             parent_award_id=None,
                                             disaster_emergency_fund_code='n',
                                             program_activity_code=None,
                                             program_activity_name=None,
                                             object_class=None,
                                             by_direct_reimbursable_fun=None,
                                             gross_outlay_amount_by_awa_cpe=5)
    paf_all_9 = PublishedAwardFinancialFactory(
        submission_id=sub_1.submission_id,
        tas='test_tas',
        fain='aBcD',
        uri='eFgH',
        piid='mNoP',
        parent_award_id='qRsT',
        disaster_emergency_fund_code='9',
        program_activity_code='c',
        program_activity_name=None,
        object_class=None,
        by_direct_reimbursable_fun=None,
        gross_outlay_amount_by_awa_cpe=5)
    paf_pac = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                             tas='test_tas',
                                             fain='hiJK',
                                             uri=None,
                                             piid=None,
                                             parent_award_id=None,
                                             disaster_emergency_fund_code='n',
                                             program_activity_code='c',
                                             program_activity_name=None,
                                             object_class=None,
                                             by_direct_reimbursable_fun=None,
                                             gross_outlay_amount_by_awa_cpe=5)
    paf_pan = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                             tas='test_tas',
                                             fain='hiJK',
                                             uri=None,
                                             piid=None,
                                             parent_award_id=None,
                                             disaster_emergency_fund_code='n',
                                             program_activity_code=None,
                                             program_activity_name='n',
                                             object_class=None,
                                             by_direct_reimbursable_fun=None,
                                             gross_outlay_amount_by_awa_cpe=5)
    paf_obj = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                             tas='test_tas',
                                             fain='hiJK',
                                             uri=None,
                                             piid=None,
                                             parent_award_id=None,
                                             disaster_emergency_fund_code='n',
                                             program_activity_code=None,
                                             program_activity_name=None,
                                             object_class='c',
                                             by_direct_reimbursable_fun=None,
                                             gross_outlay_amount_by_awa_cpe=5)
    paf_dr = PublishedAwardFinancialFactory(submission_id=sub_1.submission_id,
                                            tas='test_tas',
                                            fain='hiJK',
                                            uri=None,
                                            piid=None,
                                            parent_award_id=None,
                                            disaster_emergency_fund_code='n',
                                            program_activity_code=None,
                                            program_activity_name=None,
                                            object_class=None,
                                            by_direct_reimbursable_fun='r',
                                            gross_outlay_amount_by_awa_cpe=5)
    database.session.add_all([
        sub_1, paf_fain, paf_uri, paf_piid, paf_paid, paf_zero, paf_null,
        paf_tas, paf_all_9, paf_pac, paf_pan, paf_obj, paf_dr
    ])
    database.session.commit()

    # quarterly submission with each of the previous values (one of them is 0 now)
    sub_q = SubmissionFactory(submission_id=2,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=6,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=True,
                              is_fabs=False)
    af_fain = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=0)
    af_uri = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                   tas='test_tas',
                                   fain=None,
                                   uri='efgh',
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_piid = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='ijkl',
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=7)
    af_paid = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='mnop',
                                    parent_award_id='qrst',
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=2)
    af_zero = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                    tas='test_tas',
                                    fain='xyz',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=6)
    af_null = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                    tas='test_tas',
                                    fain='xyz',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=3)
    af_tas = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                   tas='different_tas',
                                   fain='hijk',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    af_9_match = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                       tas='test_tas',
                                       fain='aBcD',
                                       uri='eFgH',
                                       piid='mNoP',
                                       parent_award_id='qRsT',
                                       disaster_emergency_fund_code='n',
                                       program_activity_code=None,
                                       program_activity_name=None,
                                       object_class=None,
                                       by_direct_reimbursable_fun=None,
                                       gross_outlay_amount_by_awa_cpe=5)
    af_pac = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code='c',
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=1)
    af_pan = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name='n',
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    af_obj = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class='c',
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_dr = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                  tas='test_tas',
                                  fain='hiJK',
                                  uri=None,
                                  piid=None,
                                  parent_award_id=None,
                                  disaster_emergency_fund_code='n',
                                  program_activity_code=None,
                                  program_activity_name=None,
                                  object_class=None,
                                  by_direct_reimbursable_fun='r',
                                  gross_outlay_amount_by_awa_cpe=4)
    # Additional line doesn't mess anything up
    af_bonus = AwardFinancialFactory(submission_id=sub_q.submission_id,
                                     tas='something_different')

    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  af_fain, af_uri, af_piid, af_paid, af_zero,
                                  af_null, af_tas, af_9_match, af_pac, af_pan,
                                  af_obj, af_dr, af_bonus
                              ],
                              submission=sub_q)
    assert errors == 0

    # period submission with each of the previous values
    sub_p = SubmissionFactory(submission_id=3,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=4,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=True,
                              is_fabs=False)
    af_fain = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=9)
    af_uri = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                   tas='test_tas',
                                   fain=None,
                                   uri='efgh',
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_piid = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='ijkl',
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=7)
    af_paid = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='mnop',
                                    parent_award_id='qrst',
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=2)
    af_zero = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                    tas='test_tas',
                                    fain='xyz',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=6)
    af_null = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                    tas='test_tas',
                                    fain='xyz',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=3)
    af_tas = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                   tas='different_tas',
                                   fain='hijk',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    # matches the DEFC of 9 with a different DEFC
    af_9_match = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                       tas='test_tas',
                                       fain='aBcD',
                                       uri='eFgH',
                                       piid='mNoP',
                                       parent_award_id='qRsT',
                                       disaster_emergency_fund_code='n',
                                       program_activity_code=None,
                                       program_activity_name=None,
                                       object_class=None,
                                       by_direct_reimbursable_fun=None,
                                       gross_outlay_amount_by_awa_cpe=5)
    af_pac = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code='c',
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=1)
    af_pan = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name='n',
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    af_obj = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class='c',
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_dr = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                  tas='test_tas',
                                  fain='hiJK',
                                  uri=None,
                                  piid=None,
                                  parent_award_id=None,
                                  disaster_emergency_fund_code='n',
                                  program_activity_code=None,
                                  program_activity_name=None,
                                  object_class=None,
                                  by_direct_reimbursable_fun='r',
                                  gross_outlay_amount_by_awa_cpe=4)
    # Additional line doesn't mess anything up
    af_bonus = AwardFinancialFactory(submission_id=sub_p.submission_id,
                                     tas='something_different')

    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  af_fain, af_uri, af_piid, af_paid, af_zero,
                                  af_null, af_tas, af_9_match, af_pac, af_pan,
                                  af_obj, af_dr, af_bonus
                              ],
                              submission=sub_p)
    assert errors == 0

    # submission missing the values that were 0 and NULL the previous quarter does not throw errors
    sub_4 = SubmissionFactory(submission_id=4,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=6,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=True,
                              is_fabs=False)
    af_fain = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                    tas='test_tas',
                                    fain='abcd',
                                    uri=None,
                                    piid=None,
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=9)
    af_uri = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                   tas='test_tas',
                                   fain=None,
                                   uri='efgh',
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_piid = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='ijkl',
                                    parent_award_id=None,
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=7)
    af_paid = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                    tas='test_tas',
                                    fain=None,
                                    uri=None,
                                    piid='mnop',
                                    parent_award_id='qrst',
                                    disaster_emergency_fund_code='n',
                                    program_activity_code=None,
                                    program_activity_name=None,
                                    object_class=None,
                                    by_direct_reimbursable_fun=None,
                                    gross_outlay_amount_by_awa_cpe=2)
    af_tas = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                   tas='different_tas',
                                   fain='hijk',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    af_9_match = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                       tas='test_tas',
                                       fain='aBcD',
                                       uri='eFgH',
                                       piid='mNoP',
                                       parent_award_id='qRsT',
                                       disaster_emergency_fund_code='n',
                                       program_activity_code=None,
                                       program_activity_name=None,
                                       object_class=None,
                                       by_direct_reimbursable_fun=None,
                                       gross_outlay_amount_by_awa_cpe=5)
    af_pac = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code='c',
                                   program_activity_name=None,
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=1)
    af_pan = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name='n',
                                   object_class=None,
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=2)
    af_obj = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                   tas='test_tas',
                                   fain='hiJK',
                                   uri=None,
                                   piid=None,
                                   parent_award_id=None,
                                   disaster_emergency_fund_code='n',
                                   program_activity_code=None,
                                   program_activity_name=None,
                                   object_class='c',
                                   by_direct_reimbursable_fun=None,
                                   gross_outlay_amount_by_awa_cpe=3)
    af_dr = AwardFinancialFactory(submission_id=sub_4.submission_id,
                                  tas='test_tas',
                                  fain='hiJK',
                                  uri=None,
                                  piid=None,
                                  parent_award_id=None,
                                  disaster_emergency_fund_code='n',
                                  program_activity_code=None,
                                  program_activity_name=None,
                                  object_class=None,
                                  by_direct_reimbursable_fun='r',
                                  gross_outlay_amount_by_awa_cpe=4)

    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  af_fain, af_uri, af_piid, af_paid, af_tas,
                                  af_pac, af_pan, af_obj, af_dr, af_9_match
                              ],
                              submission=sub_4)
    assert errors == 0

    # submission that doesn't have a "previous period"
    sub_5 = SubmissionFactory(submission_id=5,
                              reporting_fiscal_year=2020,
                              reporting_fiscal_period=5,
                              cgac_code='test',
                              frec_code=None,
                              is_quarter_format=True)

    errors = number_of_errors(_FILE, database, models=[], submission=sub_5)
    assert errors == 0
def test_value_present(database):
    """budget_authority_unobligat_fyb populated does not require a previous submission"""
    populate_publish_status(database)
    sub_new = SubmissionFactory()
    ap_new = AppropriationFactory(submission_id=sub_new.submission_id)
    assert number_of_errors(_FILE, database, submission=sub_new, models=[ap_new]) == 0