def test_success_populated_ata_frec(database):
    """
        Tests that TAS for SF-133 are present in File A for FREC submissions
        Note this aspect of the filter is only relevant to FRECs 1601 and 1125
    """
    submission_id = randint(1000, 10000)
    tas, period, year, cgac_code, frec_code = 'some-tas', 2, 2002, '016', '1601'

    sf = SF133Factory(tas=tas,
                      period=period,
                      fiscal_year=year,
                      allocation_transfer_agency=cgac_code,
                      agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf, ap],
                      submission=submission) == []

    submission_id = randint(1000, 10000)
    tas, period, year, cgac_code, frec_code = 'some-tas', 2, 2002, '011', '1125'

    sf = SF133Factory(tas=tas,
                      period=period,
                      fiscal_year=year,
                      allocation_transfer_agency=cgac_code,
                      agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf, ap],
                      submission=submission) == []

    # testing with a not special FREC to show it'd still pass cause it doesn't link
    submission_id = randint(1000, 10000)
    tas, period, year, cgac_code, frec_code = 'some-tas', 2, 2002, '011', '1124'

    sf = SF133Factory(tas=tas,
                      period=period,
                      fiscal_year=year,
                      allocation_transfer_agency=cgac_code,
                      agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf, ap],
                      submission=submission) == []
示例#2
0
def test_success(database):
    """ Tests that SF 133 amount sum for lines 1340, 1440 matches Appropriation borrowing_authority_amount_cpe for the
        specified fiscal year and period
    """
    tas_1 = "".join([_TAS, "_success"])
    tas_2 = "".join([_TAS, "_success_2"])

    sf_1 = SF133Factory(line=1340,
                        tas=tas_1,
                        period=1,
                        fiscal_year=2016,
                        amount=1)
    sf_2 = SF133Factory(line=1440,
                        tas=tas_1,
                        period=1,
                        fiscal_year=2016,
                        amount=1)
    sf_3 = SF133Factory(line=1340,
                        tas=tas_2,
                        period=1,
                        fiscal_year=2016,
                        amount=0)
    sf_4 = SF133Factory(line=1440,
                        tas=tas_2,
                        period=1,
                        fiscal_year=2016,
                        amount=0)
    ap_1 = AppropriationFactory(tas=tas_1, borrowing_authority_amount_cpe=2)
    ap_2 = AppropriationFactory(tas=tas_2, borrowing_authority_amount_cpe=None)

    assert number_of_errors(_FILE,
                            database,
                            models=[sf_1, sf_2, sf_3, sf_4, ap_1, ap_2]) == 0
def test_financing_tas(database):
    """ GTAS entries associated with a CARS with a "financing" financial indicator should be ignored"""
    cars_1 = TASFactory(financial_indicator2='other indicator')
    cars_2 = TASFactory(financial_indicator2=None)

    gtas_1 = SF133Factory(account_num=cars_1.account_num,
                          allocation_transfer_agency=None,
                          disaster_emergency_fund_code='N',
                          line=3020,
                          amount=4)
    gtas_2 = SF133Factory(account_num=cars_2.account_num,
                          period=gtas_1.period,
                          fiscal_year=gtas_1.fiscal_year,
                          agency_identifier=gtas_1.agency_identifier,
                          allocation_transfer_agency=None,
                          disaster_emergency_fund_code='N',
                          line=3020,
                          amount=4)

    submission = SubmissionFactory(reporting_fiscal_period=gtas_1.period,
                                   reporting_fiscal_year=gtas_1.fiscal_year,
                                   cgac_code=gtas_1.agency_identifier,
                                   is_quarter_format=False)

    errors = number_of_errors(_FILE,
                              database,
                              models=[gtas_1, gtas_2, cars_1, cars_2],
                              submission=submission)
    assert errors == 2

    cars_3 = TASFactory(financial_indicator2='f')
    cars_4 = TASFactory(financial_indicator2='F')

    gtas_3 = SF133Factory(account_num=cars_3.account_num,
                          allocation_transfer_agency=None,
                          disaster_emergency_fund_code='N')
    gtas_4 = SF133Factory(account_num=cars_4.account_num,
                          period=gtas_3.period,
                          fiscal_year=gtas_3.fiscal_year,
                          agency_identifier=gtas_3.agency_identifier,
                          allocation_transfer_agency=None,
                          disaster_emergency_fund_code='N')

    submission = SubmissionFactory(reporting_fiscal_period=gtas_3.period,
                                   reporting_fiscal_year=gtas_3.fiscal_year,
                                   cgac_code=gtas_3.agency_identifier,
                                   is_quarter_format=False)

    errors = number_of_errors(_FILE,
                              database,
                              models=[gtas_3, gtas_4, cars_3, cars_4],
                              submission=submission)
    assert errors == 0
示例#4
0
def test_failure(database):
    """ Tests that SF 133 amount sum for lines 1340, 1440 does not match Appropriation borrowing_authority_amount_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_failure"])

    sf_1 = SF133Factory(line=1340, tas=tas, period=1, fiscal_year=2016,
                        amount=1)
    sf_2 = SF133Factory(line=1440, tas=tas, period=1, fiscal_year=2016,
                        amount=1)
    ap = AppropriationFactory(tas=tas, borrowing_authority_amount_cpe=1)

    models = [sf_1, sf_2, ap]

    assert number_of_errors(_FILE, database, models=models) == 1
def test_failure_populated_ata_frec(database):
    """
        Tests that TAS for SF-133 are present in File A for FREC submissions
        Note this aspect of the filter is only relevant to FRECs 1601 and 1125
    """
    submission_id = randint(1000, 10000)
    tas, period, year, cgac_code, frec_code = 'some-tas', 2, 2002, '016', '1601'

    sf = SF133Factory(tas=tas,
                      period=period,
                      fiscal_year=year,
                      allocation_transfer_agency=cgac_code,
                      agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf, ap],
                              submission=submission)
    assert errors == 1

    submission_id = randint(1000, 10000)
    tas, period, year, cgac_code, frec_code = 'some-tas', 2, 2002, '011', '1125'

    sf = SF133Factory(tas=tas,
                      period=period,
                      fiscal_year=year,
                      allocation_transfer_agency=cgac_code,
                      agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf, ap],
                              submission=submission)
    assert errors == 1
def test_failure_populated_011_fr_entity_cgac(database):
    """ Tests that TAS for SF-133 are present in File A for CGAC submissions """
    submission_id = randint(1000, 10000)
    tas, account_num, period, year, cgac_code, frec_code = 'some-tas', 1, 2, 2002, 'some-cgac-code', 'some-frec-code'

    cgac = CGACFactory(cgac_code=cgac_code, cgac_id=1)
    frec = FRECFactory(cgac_id=cgac.cgac_id, frec_code=frec_code, frec_id=1)
    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier='011',
                       account_num=account_num)
    ts1 = TASFactory(account_num=account_num, fr_entity_type=frec_code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=cgac_code,
                                   frec_code=None)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[cgac, frec, sf1, ts1, ap],
                              submission=submission)
    assert errors == 1
def test_success_null_ata(database):
    """ Tests that TAS/DEFC for SF-133 are present in File B (null ATA) """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier=code,
                       disaster_emergency_fund_code='N',
                       line=2190,
                       amount=4)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   is_quarter_format=False)
    op = ObjectClassProgramActivityFactory(tas=tas,
                                           disaster_emergency_fund_code='n',
                                           submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, op],
                              submission=submission)
    assert errors == 0
def test_non_matching_defc(database):
    """ Tests that even if TAS matches, if DEFC doesn't it throws an error """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier='some-other-code',
                       disaster_emergency_fund_code='N',
                       line=3020,
                       amount=4)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   is_quarter_format=False)
    op = ObjectClassProgramActivityFactory(tas=tas,
                                           disaster_emergency_fund_code='m',
                                           submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, op],
                              submission=submission)
    assert errors == 1
def test_ignore_quarterly_submissions(database):
    """ Tests that rule doesn't apply to quarterly submissions """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier=code,
                       disaster_emergency_fund_code='N',
                       line=3020,
                       amount=4)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   is_quarter_format=True)
    op = ObjectClassProgramActivityFactory(tas='a-different-tas',
                                           submission_id=submission_id,
                                           disaster_emergency_fund_code='n')

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, op],
                              submission=submission)
    assert errors == 0
示例#10
0
def test_update_tas_ids_fiscal_year(database):
    """Fiscal year math should be accurate when checking TAS entries"""
    sess = database.session
    tas = TASFactory(internal_start_date=date(2010, 1, 1),
                     internal_end_date=date(2010, 8, 31))
    copied_fields = {   # translate to a slightly different set of fields
        'allocation_transfer_agency': tas.allocation_transfer_agency,
        'agency_identifier': tas.agency_identifier,
        'beginning_period_of_availa': tas.beginning_period_of_availability,
        'ending_period_of_availabil': tas.ending_period_of_availability,
        'availability_type_code': tas.availability_type_code,
        'main_account_code': tas.main_account_code,
        'sub_account_code': tas.sub_account_code
    }
    sf_133 = SF133Factory(fiscal_year=2011, period=1, **copied_fields)
    sess.add_all([tas, sf_133])
    sess.commit()

    load_sf133.update_tas_id(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.tas_id is None

    tas.internal_end_date = date(2010, 9, 30)
    sess.commit()
    load_sf133.update_tas_id(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.tas_id is None

    tas.internal_end_date = date(2010, 10, 31)
    sess.commit()
    load_sf133.update_tas_id(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.tas_id is tas.tas_id
示例#11
0
def test_success_multi_line(database):
    """ Tests that the validation is still successful if there are multiple SF-133 lines because of DEFC splits. """

    sf_1 = SF133Factory(line=2490,
                        tas=_TAS,
                        period=12,
                        fiscal_year=2015,
                        amount=1)
    sf_2 = SF133Factory(line=2490,
                        tas=_TAS,
                        period=12,
                        fiscal_year=2015,
                        amount=4)
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=5)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap]) == 0
def test_failure(database):
    """ Test failure TotalBudgetaryResources_CPE = BudgetAuthorityAppropriatedAmount_CPE +
        BudgetAuthorityUnobligatedBalanceBroughtForward_FYB + AdjustmentsToUnobligatedBalanceBroughtForward_CPE +
        OtherBudgetaryResourcesAmount_CPE + SF 133 Line 1902
    """

    approp = AppropriationFactory(total_budgetary_resources_cpe=1200,
                                  budget_authority_appropria_cpe=100,
                                  budget_authority_unobligat_fyb=200,
                                  adjustments_to_unobligated_cpe=300,
                                  other_budgetary_resources_cpe=400,
                                  tas='abcd')
    approp_null = AppropriationFactory(total_budgetary_resources_cpe=800,
                                       budget_authority_appropria_cpe=100,
                                       budget_authority_unobligat_fyb=200,
                                       adjustments_to_unobligated_cpe=300,
                                       other_budgetary_resources_cpe=None,
                                       tas='abcd')
    approp_wrong_tas = AppropriationFactory(total_budgetary_resources_cpe=1000,
                                            budget_authority_appropria_cpe=100,
                                            budget_authority_unobligat_fyb=200,
                                            adjustments_to_unobligated_cpe=300,
                                            other_budgetary_resources_cpe=400,
                                            tas='bcda')

    # approp_wrong
    sf_1 = SF133Factory(line=1902,
                        tas='bcda',
                        period=1,
                        fiscal_year=2016,
                        amount=100)

    errors = number_of_errors(
        _FILE, database, models=[approp, approp_null, approp_wrong_tas, sf_1])
    assert errors == 3
示例#13
0
def test_success_fyb_sum_zero(database):
    """ Testing that the rule passes if the sum of the SF133 lines is 0 """
    sf_1 = SF133Factory(line=1000,
                        tas=_TAS,
                        period=1,
                        fiscal_year=2016,
                        amount=1,
                        disaster_emergency_fund_code='Q')
    sf_2 = SF133Factory(line=1000,
                        tas=_TAS,
                        period=1,
                        fiscal_year=2016,
                        amount=-1,
                        disaster_emergency_fund_code='B')
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap]) == 0
def test_failure_populated_ata_cgac(database):
    """ Tests that TAS for SF-133 are not present in File A for CGAC submissions """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier=code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   frec_code=None)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, ap],
                              submission=submission)
    assert errors == 1

    # accounting for CGAC 097, should still link with ata 021
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, '097'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency='021',
                       agency_identifier='some-other-code')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   frec_code=None)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, ap],
                              submission=submission)
    assert errors == 1
def test_success_ignore_lines(database):
    """ Tests lines that should be ignored in SF133 are """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier='some-other-code',
                       disaster_emergency_fund_code='N',
                       line=3020,
                       amount=4)
    # Invalid line number
    sf2 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier='some-other-code',
                       disaster_emergency_fund_code='M',
                       line=1000,
                       amount=4)
    # amount of 0
    sf3 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier='some-other-code',
                       disaster_emergency_fund_code='L',
                       line=3020,
                       amount=0)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   is_quarter_format=False)
    op = ObjectClassProgramActivityFactory(tas=tas,
                                           disaster_emergency_fund_code='n',
                                           submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, sf2, sf3, op],
                              submission=submission)
    assert errors == 0
示例#16
0
def test_failure(database):
    """ Tests that if the SF-133 amount for line 1000 for the same fiscal year and period is populated, then
        Appropriation budget_authority_unobligat_fyb is not populated
    """

    sf = SF133Factory(line=1000, tas=_TAS, period=1, fiscal_year=2016, amount=1)
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 1
示例#17
0
def test_success_fyb_none(database):
    sf = SF133Factory(line=1000,
                      tas=_TAS,
                      period=1,
                      fiscal_year=2016,
                      amount=0)
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 0
示例#18
0
def test_failure(database):
    """ Tests that BorrowingAuthorityAmountTotal_CPE is not provided if TAS has borrowing authority value
    provided in GTAS """
    tas = "".join([_TAS, "_failure"])

    sf1 = SF133Factory(tas=tas,
                       period=1,
                       fiscal_year=2016,
                       line=1340,
                       amount=1)
    sf2 = SF133Factory(tas=tas,
                       period=1,
                       fiscal_year=2016,
                       line=1440,
                       amount=1)

    ap = AppropriationFactory(tas=tas, borrowing_authority_amount_cpe=0)

    assert number_of_errors(_FILE, database, models=[sf1, sf2, ap]) == 1
def test_success(database):
    """ Tests that ContractAuthorityAmountTotal_CPE is provided if TAS has spending authority value
    provided in GTAS """
    tas = "".join([_TAS, "_success"])

    sf1 = SF133Factory(tas=tas,
                       period=1,
                       fiscal_year=2016,
                       line=1750,
                       amount=1)
    sf2 = SF133Factory(tas=tas,
                       period=1,
                       fiscal_year=2016,
                       line=1850,
                       amount=1)

    ap = AppropriationFactory(tas=tas, spending_authority_from_of_cpe=1)

    assert number_of_errors(_FILE, database, models=[sf1, sf2, ap]) == 0
示例#20
0
def test_success(database):
    """ Tests that if the SF-133 amount for line 1000 for the same fiscal year and period is populated, then
        Appropriation budget_authority_unobligat_fyb is also populated
    """

    sf_1 = SF133Factory(line=1000,
                        tas=_TAS,
                        period=1,
                        fiscal_year=2016,
                        amount=1,
                        disaster_emergency_fund_code='Q')
    sf_2 = SF133Factory(line=1000,
                        tas=_TAS,
                        period=1,
                        fiscal_year=2016,
                        amount=1,
                        disaster_emergency_fund_code='B')
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=1)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap]) == 0
def test_success(database):
    """ Tests that TAS for File A are present in SF-133 """
    tas = "".join([_TAS, "_success"])

    ap1 = AppropriationFactory(job_id=1, row_number=1, tas=tas)
    ap2 = AppropriationFactory(job_id=1, row_number=2, tas=tas)

    sf = SF133Factory(line=1021, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
                      main_account_code="000", sub_account_code="000")

    assert number_of_errors(_FILE, database, models=[ap1, ap2, sf]) == 0
def test_success_fy2016(database):
    """ If data for the end of the last fiscal year isn't present, the validation should still pass since it only looks
        for a specific fiscal year and period when executing the SQL
    """
    sf = SF133Factory(line=2490,
                      tas=_TAS,
                      period=12,
                      fiscal_year=2016,
                      amount=1)
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=0)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 0
def test_failure(database):
    """ Tests that SF-133 amount for line 2490 for the end of the last fiscal year
    does not equal Appropriation budget_authority_unobligat_fyb """

    sf = SF133Factory(line=2490,
                      tas=_TAS,
                      period=12,
                      fiscal_year=2015,
                      amount=1)
    ap = AppropriationFactory(tas=_TAS, budget_authority_unobligat_fyb=0)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 1
def test_success_populated_aid_cgac(database):
    """ Tests that TAS for SF-133 are present in File A for CGAC submissions """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier=code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   frec_code=None)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf1, ap],
                      submission=submission) == []

    # accounting for CGAC 097, should still link with 017
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, '097'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier='017')
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code,
                                   frec_code=None)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf1, ap],
                      submission=submission) == []
示例#25
0
def test_success_null_ata(database):
    """ Tests that TAS for SF-133 are present in File A """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier=code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE, database, models=[sf1, ap],
                      submission=submission) == []
def test_failure_with_rule_exception(database):
    """ Tests that TAS for File A are not present in SF-133
    except when all monetary amounts are zero for the TAS"""
    tas = "".join([_TAS, "_failure"])

    ap1 = AppropriationFactory(job_id=1, row_number=1, tas=tas, adjustments_to_unobligated_cpe=1)
    ap2 = AppropriationFactory(job_id=1, row_number=2, tas=tas, budget_authority_appropria_cpe=2)
    ap3 = AppropriationFactory(job_id=1, row_number=3, tas=tas, adjustments_to_unobligated_cpe=0,
                               budget_authority_appropria_cpe=0, borrowing_authority_amount_cpe=0,
                               contract_authority_amount_cpe=0, spending_authority_from_of_cpe=0,
                               other_budgetary_resources_cpe=0, total_budgetary_resources_cpe=0,
                               gross_outlay_amount_by_tas_cpe=0, obligations_incurred_total_cpe=0,
                               deobligations_recoveries_r_cpe=0, unobligated_balance_cpe=0,
                               status_of_budgetary_resour_cpe=0)

    sf = SF133Factory(line=1021, tas='1', period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
                      main_account_code="000", sub_account_code="000")

    assert number_of_errors(_FILE, database, models=[ap1, ap2, ap3, sf]) == 2
def test_financing_tas(database):
    """GTAS entries associated with a CARS with a "financing" financial
    indicator should be ignored"""
    cars = TASFactory()
    database.session.add(cars)
    database.session.commit()
    gtas = SF133Factory(tas_id=cars.tas_id)
    submission = SubmissionFactory(reporting_fiscal_period=gtas.period,
                                   reporting_fiscal_year=gtas.fiscal_year,
                                   cgac_code=gtas.allocation_transfer_agency)
    errors = number_of_errors(_FILE,
                              database,
                              models=[gtas, cars],
                              submission=submission)
    assert errors == 1

    cars.financial_indicator2 = 'F'
    assert error_rows(_FILE,
                      database,
                      models=[gtas, cars],
                      submission=submission) == []
示例#28
0
def test_failure_populated_ata(database):
    """ Tests that TAS for SF-133 are not present in File A """
    submission_id = randint(1000, 10000)
    tas, period, year, code = 'some-tas', 2, 2002, 'some-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=code,
                       agency_identifier=code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=code)
    ap = AppropriationFactory(tas='a-different-tas',
                              submission_id=submission_id)

    errors = number_of_errors(_FILE,
                              database,
                              models=[sf1, ap],
                              submission=submission)
    assert errors == 1
def test_update_account_nums_fiscal_year(database):
    """ Fiscal year math should be accurate when checking TAS entries """
    sess = database.session
    tas = TASFactory(internal_start_date=date(2010, 1, 1), internal_end_date=date(2010, 8, 31))
    sf_133 = SF133Factory(fiscal_year=2011, period=1, **tas.component_dict())
    sess.add_all([tas, sf_133])
    sess.commit()

    load_sf133.update_account_num(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.account_num is None

    tas.internal_end_date = date(2010, 9, 30)
    sess.commit()
    load_sf133.update_account_num(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.account_num is None

    tas.internal_end_date = date(2010, 10, 31)
    sess.commit()
    load_sf133.update_account_num(2011, 1)
    sess.refresh(sf_133)
    assert sf_133.account_num == tas.account_num
def test_success_populated_aid_fr_entity_frec(database):
    """ Tests that TAS for SF-133 are present in File A for FREC submissions """
    submission_id = randint(1000, 10000)
    tas, account_num, period, year, cgac_code, frec_code = 'some-tas', 1, 2, 2002, 'some-cgac-code', 'some-frec-code'

    sf1 = SF133Factory(tas=tas,
                       period=period,
                       fiscal_year=year,
                       allocation_transfer_agency=None,
                       agency_identifier=cgac_code,
                       account_num=account_num)
    ts1 = TASFactory(account_num=account_num, fr_entity_type=frec_code)
    submission = SubmissionFactory(submission_id=submission_id,
                                   reporting_fiscal_period=period,
                                   reporting_fiscal_year=year,
                                   cgac_code=None,
                                   frec_code=frec_code)
    ap = AppropriationFactory(tas=tas, submission_id=submission_id)

    assert error_rows(_FILE,
                      database,
                      models=[sf1, ts1, ap],
                      submission=submission) == []