def test_success(database):
    """ Tests that SF 133 amount sum for lines 1540, 1640 matches Appropriation contract_authority_amount_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_success"])

    sf_1 = SF133(line=1540,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1640,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       contract_authority_amount_cpe=2)

    models = [sf_1, sf_2, ap]

    assert number_of_errors(_FILE, database, models=models) == 0
Esempio n. 2
0
def test_success(database):
    """ Tests that SF 133 amount for line 1000 matches Appropriation budget_authority_unobligat_fyb for the specified
        fiscal year and period
    """
    tas_1 = "".join([_TAS, "_success"])
    tas_2 = "".join([_TAS, "_success_2"])

    sf_1 = SF133(line=1000,
                 tas=tas_1,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1000,
                 tas=tas_2,
                 period=1,
                 fiscal_year=2016,
                 amount=0,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap_1 = Appropriation(job_id=1,
                         row_number=1,
                         tas=tas_1,
                         budget_authority_unobligat_fyb=1)
    ap_2 = Appropriation(job_id=2,
                         row_number=1,
                         tas=tas_2,
                         budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap_1,
                                                     ap_2]) == 0
Esempio n. 3
0
def test_failure(database):
    """ Tests that SF 133 amount sum for lines 1750, 1850 does not match Appropriation spending_authority_from_of_cpe
        for the specified fiscal year and period
    """
    tas = "".join([_TAS, "_failure"])

    sf_1 = SF133(line=1750,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1850,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap_1 = Appropriation(job_id=1,
                         row_number=1,
                         tas=tas,
                         spending_authority_from_of_cpe=1)
    ap_2 = Appropriation(job_id=1,
                         row_number=1,
                         tas=tas,
                         spending_authority_from_of_cpe=None)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap_1,
                                                     ap_2]) == 2
def test_failure(database):
    """ Tests that SF 133 amount sum for lines 1021, 1033 does not match Appropriation deobligations_recoveries_r_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_failure"])

    sf_1 = SF133(line=1021, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")
    sf_2 = SF133(line=1033, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")
    ap = Appropriation(job_id=1, row_number=1, tas=tas, deobligations_recoveries_r_cpe=1)

    models = [sf_1, sf_2, ap]

    assert number_of_errors(_FILE, database, models=models) == 1
def test_success(database):
    """ Tests that SF 133 amount for line 1910 matches Appropriation total_budgetary_resources_cpe
        for the specified fiscal year and period
    """

    tas = 'tas_one_line'

    sf = SF133(line=1910,
               tas=tas,
               period=1,
               fiscal_year=2016,
               amount=1,
               agency_identifier='sys',
               main_account_code='000',
               sub_account_code='000')
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       total_budgetary_resources_cpe=1)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 0

    # Test with split SF133 lines
    tas = 'tas_two_lines'

    sf_1 = SF133(line=1910,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000',
                 disaster_emergency_fund_code='n')
    sf_2 = SF133(line=1910,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=4,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000',
                 disaster_emergency_fund_code='o')
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       total_budgetary_resources_cpe=5)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap]) == 0
def test_success(database):
    """ Tests that SF 133 amount sum for line 2004 matches the calculation from Appropriation based on the fields below
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_success"])

    # This uses the default submission created in utils for 10/2015 which is period 1 of FY 2016
    sf = SF133(line=2004, tas=tas, period=1, fiscal_year=2016, amount=-15, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")

    op = ObjectClassProgramActivity(job_id=1, row_number=1, tas=tas, by_direct_reimbursable_fun='d',
                                    ussgl480100_undelivered_or_cpe=1, ussgl480100_undelivered_or_fyb=1,
                                    ussgl480200_undelivered_or_cpe=1, ussgl480200_undelivered_or_fyb=1,
                                    ussgl488100_upward_adjustm_cpe=1, ussgl488200_upward_adjustm_cpe=1,
                                    ussgl490100_delivered_orde_cpe=1, ussgl490100_delivered_orde_fyb=1,
                                    ussgl490200_delivered_orde_cpe=1, ussgl490800_authority_outl_cpe=1,
                                    ussgl490800_authority_outl_fyb=1, ussgl498100_upward_adjustm_cpe=1,
                                    ussgl498200_upward_adjustm_cpe=1)

    op2 = ObjectClassProgramActivity(job_id=1, row_number=2, tas=tas, by_direct_reimbursable_fun='d',
                                    ussgl480100_undelivered_or_cpe=2, ussgl480100_undelivered_or_fyb=2,
                                    ussgl480200_undelivered_or_cpe=2, ussgl480200_undelivered_or_fyb=2,
                                    ussgl488100_upward_adjustm_cpe=2, ussgl488200_upward_adjustm_cpe=2,
                                    ussgl490100_delivered_orde_cpe=2, ussgl490100_delivered_orde_fyb=2,
                                    ussgl490200_delivered_orde_cpe=2, ussgl490800_authority_outl_cpe=2,
                                    ussgl490800_authority_outl_fyb=2, ussgl498100_upward_adjustm_cpe=2,
                                    ussgl498200_upward_adjustm_cpe=2)

    assert number_of_errors(_FILE, database, models=[sf, op, op2]) == 0
def test_success(database):
    """ Tests that SF 133 amount sum for lines 1010 through 1042 matches Appropriation adjustments_to_unobligated_cpe
        for the specified fiscal year and period
    """
    tas = "".join([_TAS, "_success"])

    sf_1 = SF133(line=1020,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1030,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_3 = SF133(line=1040,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    # This line should be ignored because it's before 2021
    sf_4 = SF133(line=1060,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=10,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       adjustments_to_unobligated_cpe=3)

    models = [sf_1, sf_2, sf_3, sf_4, ap]

    assert number_of_errors(_FILE, database, models=models) == 0
def test_failure(database):
    """ Tests that SF 133 amount sum for lines 1160, 1180, 1260, 1280 does not match Appropriation budget_authority_appropria_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_failure"])

    sf_1 = SF133(line=1160,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1180,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_3 = SF133(line=1260,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_4 = SF133(line=1280,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       budget_authority_appropria_cpe=1)

    models = [sf_1, sf_2, sf_3, sf_4, ap]

    assert number_of_errors(_FILE, database, models=models) == 1
Esempio n. 9
0
def test_failure(database):
    """ Tests that SF 133 amount sum for line 3020 does not match Appropriation gross_outlay_amount_by_tas_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_failure"])

    sf = SF133(line=3020, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")
    ap = Appropriation(job_id=1, row_number=1, tas=tas, gross_outlay_amount_by_tas_cpe=0)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 1
Esempio n. 10
0
def test_success(database):
    """ Tests that SF 133 amount sum for line 2490 matches Appropriation unobligated_balance_cpe
        for the specified fiscal year and period """
    tas = "".join([_TAS, "_success"])

    sf = SF133(line=2490, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")
    ap = Appropriation(job_id=1, row_number=1, tas=tas, unobligated_balance_cpe=1)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 0
def test_failure(database):
    """ Tests that SF 133 amount sum for line 2004 does not match the calculation from Appropriation based on
        the fields below for the specified fiscal year and period and TAS/DEFC combination.
    """
    tas = "".join([_TAS, "_failure"])
    sf = SF133(line=2004,
               tas=tas,
               period=1,
               fiscal_year=2016,
               amount=5,
               agency_identifier="sys",
               main_account_code="000",
               sub_account_code="000",
               disaster_emergency_fund_code='D')

    op = ObjectClassProgramActivity(job_id=1,
                                    row_number=1,
                                    tas=tas,
                                    by_direct_reimbursable_fun='d',
                                    ussgl480100_undelivered_or_cpe=1,
                                    ussgl480100_undelivered_or_fyb=1,
                                    ussgl480200_undelivered_or_cpe=1,
                                    ussgl480200_undelivered_or_fyb=1,
                                    ussgl488100_upward_adjustm_cpe=1,
                                    ussgl488200_upward_adjustm_cpe=1,
                                    ussgl490100_delivered_orde_cpe=1,
                                    ussgl490100_delivered_orde_fyb=1,
                                    ussgl490200_delivered_orde_cpe=1,
                                    ussgl490800_authority_outl_cpe=1,
                                    ussgl490800_authority_outl_fyb=1,
                                    ussgl498100_upward_adjustm_cpe=1,
                                    ussgl498200_upward_adjustm_cpe=1,
                                    disaster_emergency_fund_code='D')

    op2 = ObjectClassProgramActivity(job_id=1,
                                     row_number=2,
                                     tas=tas,
                                     by_direct_reimbursable_fun='d',
                                     ussgl480100_undelivered_or_cpe=2,
                                     ussgl480100_undelivered_or_fyb=2,
                                     ussgl480200_undelivered_or_cpe=2,
                                     ussgl480200_undelivered_or_fyb=2,
                                     ussgl488100_upward_adjustm_cpe=2,
                                     ussgl488200_upward_adjustm_cpe=2,
                                     ussgl490100_delivered_orde_cpe=2,
                                     ussgl490100_delivered_orde_fyb=2,
                                     ussgl490200_delivered_orde_cpe=2,
                                     ussgl490800_authority_outl_cpe=2,
                                     ussgl490800_authority_outl_fyb=2,
                                     ussgl498100_upward_adjustm_cpe=2,
                                     ussgl498200_upward_adjustm_cpe=2,
                                     disaster_emergency_fund_code='D')

    assert number_of_errors(_FILE, database, models=[sf, op, op2]) == 1
Esempio n. 12
0
def test_failure(database):
    """ Tests that SF 133 amount sum for line 2500 does not match Appropriation status_of_budgetary_resour_cpe
        for the specified fiscal year and period
    """
    tas = 'fail_tas'

    sf = SF133(line=2500, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier='sys',
               main_account_code='000', sub_account_code='000')
    ap = Appropriation(job_id=1, row_number=1, tas=tas, status_of_budgetary_resour_cpe=0)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 1
Esempio n. 13
0
def test_failure(database):
    """ Tests that SF 133 amount for line 1000 does not match Appropriation budget_authority_unobligat_fyb for the
        specified fiscal year and period
    """
    tas = "".join([_TAS, "_failure"])

    sf = SF133(line=1000, tas=tas, period=1, fiscal_year=2016, amount=1, agency_identifier="sys",
               main_account_code="000", sub_account_code="000")
    ap_1 = Appropriation(job_id=1, row_number=1, tas=tas, budget_authority_unobligat_fyb=0)
    ap_2 = Appropriation(job_id=2, row_number=1, tas=tas, budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf, ap_1, ap_2]) == 2
def test_failure(database):
    """ Tests that SF 133 amount sum for lines 1010 through 1042 does not match Appropriation
        adjustments_to_unobligated_cpe for the specified fiscal year and period
    """
    tas = "".join([_TAS, "_failure"])

    sf_1 = SF133(line=1020,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_2 = SF133(line=1030,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    sf_3 = SF133(line=1040,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier="sys",
                 main_account_code="000",
                 sub_account_code="000")
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       adjustments_to_unobligated_cpe=1)

    models = [sf_1, sf_2, sf_3, ap]

    assert number_of_errors(_FILE, database, models=models) == 1
Esempio n. 15
0
def test_failure(database):
    """ Tests that TAS for File A are not present in SF-133 """
    tas = "".join([_TAS, "_failure"])

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

    sf = SF133(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, sf]) == 2
Esempio n. 16
0
def test_success(database):
    """ Tests that SF 133 amount for line 1910 matches Appropriation total_budgetary_resources_cpe
        for the specified fiscal year and period """

    tas = "".join([_TAS, "_success"])

    sf = SF133(line=1910,
               tas=tas,
               period=1,
               fiscal_year=2016,
               amount=1,
               agency_identifier="sys",
               main_account_code="000",
               sub_account_code="000")
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       total_budgetary_resources_cpe=1)

    assert number_of_errors(_FILE, database, models=[sf, ap]) == 0
Esempio n. 17
0
def test_success(database):
    """ Tests that SF 133 amount sum for line 2104 matches the calculation from Appropriation based on the fields below
        for the specified fiscal year and period and TAS/DEFC combination.
    """
    tas = "".join([_TAS, "_success"])
    tas2 = "".join([_TAS, "_other_tas"])

    # This uses the default submission created in utils for 10/2015 which is period 1 of FY 2016
    sf = SF133(line=2104,
               tas=tas,
               period=1,
               fiscal_year=2016,
               amount=-15,
               agency_identifier="sys",
               main_account_code="000",
               sub_account_code="000",
               disaster_emergency_fund_code='Q')

    op = ObjectClassProgramActivity(job_id=1,
                                    row_number=1,
                                    tas=tas,
                                    by_direct_reimbursable_fun='r',
                                    ussgl480100_undelivered_or_cpe=1,
                                    ussgl480100_undelivered_or_fyb=1,
                                    ussgl480200_undelivered_or_cpe=1,
                                    ussgl480200_undelivered_or_fyb=1,
                                    ussgl488100_upward_adjustm_cpe=1,
                                    ussgl488200_upward_adjustm_cpe=1,
                                    ussgl490100_delivered_orde_cpe=1,
                                    ussgl490100_delivered_orde_fyb=1,
                                    ussgl490200_delivered_orde_cpe=1,
                                    ussgl490800_authority_outl_cpe=1,
                                    ussgl490800_authority_outl_fyb=1,
                                    ussgl498100_upward_adjustm_cpe=1,
                                    ussgl498200_upward_adjustm_cpe=1,
                                    disaster_emergency_fund_code='Q')
    op2 = ObjectClassProgramActivity(job_id=1,
                                     row_number=2,
                                     tas=tas,
                                     by_direct_reimbursable_fun='r',
                                     ussgl480100_undelivered_or_cpe=2,
                                     ussgl480100_undelivered_or_fyb=2,
                                     ussgl480200_undelivered_or_cpe=2,
                                     ussgl480200_undelivered_or_fyb=2,
                                     ussgl488100_upward_adjustm_cpe=2,
                                     ussgl488200_upward_adjustm_cpe=2,
                                     ussgl490100_delivered_orde_cpe=2,
                                     ussgl490100_delivered_orde_fyb=2,
                                     ussgl490200_delivered_orde_cpe=2,
                                     ussgl490800_authority_outl_cpe=2,
                                     ussgl490800_authority_outl_fyb=2,
                                     ussgl498100_upward_adjustm_cpe=2,
                                     ussgl498200_upward_adjustm_cpe=2,
                                     disaster_emergency_fund_code='q')

    # Record for other TAS should not be included in sum
    op3 = ObjectClassProgramActivity(job_id=1,
                                     row_number=3,
                                     tas=tas2,
                                     by_direct_reimbursable_fun='r',
                                     ussgl480100_undelivered_or_cpe=2,
                                     ussgl480100_undelivered_or_fyb=2,
                                     ussgl480200_undelivered_or_cpe=2,
                                     ussgl480200_undelivered_or_fyb=2,
                                     ussgl488100_upward_adjustm_cpe=2,
                                     ussgl488200_upward_adjustm_cpe=2,
                                     ussgl490100_delivered_orde_cpe=2,
                                     ussgl490100_delivered_orde_fyb=2,
                                     ussgl490200_delivered_orde_cpe=2,
                                     ussgl490800_authority_outl_cpe=2,
                                     ussgl490800_authority_outl_fyb=2,
                                     ussgl498100_upward_adjustm_cpe=2,
                                     ussgl498200_upward_adjustm_cpe=2,
                                     disaster_emergency_fund_code='q')
    # Record for other DEFC should not be included in sum
    op4 = ObjectClassProgramActivity(job_id=1,
                                     row_number=3,
                                     tas=tas,
                                     by_direct_reimbursable_fun='r',
                                     ussgl480100_undelivered_or_cpe=2,
                                     ussgl480100_undelivered_or_fyb=2,
                                     ussgl480200_undelivered_or_cpe=2,
                                     ussgl480200_undelivered_or_fyb=2,
                                     ussgl488100_upward_adjustm_cpe=2,
                                     ussgl488200_upward_adjustm_cpe=2,
                                     ussgl490100_delivered_orde_cpe=2,
                                     ussgl490100_delivered_orde_fyb=2,
                                     ussgl490200_delivered_orde_cpe=2,
                                     ussgl490800_authority_outl_cpe=2,
                                     ussgl490800_authority_outl_fyb=2,
                                     ussgl498100_upward_adjustm_cpe=2,
                                     ussgl498200_upward_adjustm_cpe=2,
                                     disaster_emergency_fund_code='D')

    assert number_of_errors(_FILE, database, models=[sf, op, op2, op3,
                                                     op4]) == 0
Esempio n. 18
0
def test_success(database):
    """ Tests that SF 133 amount for line 1000 matches Appropriation budget_authority_unobligat_fyb for the specified
        fiscal year and period
    """
    tas_1 = 'tas_one_line_1'
    tas_2 = 'tas_one_line_2'

    sf_1 = SF133(line=1000,
                 tas=tas_1,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000')
    sf_2 = SF133(line=1000,
                 tas=tas_2,
                 period=1,
                 fiscal_year=2016,
                 amount=0,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000')
    ap_1 = Appropriation(job_id=1,
                         row_number=1,
                         tas=tas_1,
                         budget_authority_unobligat_fyb=1)
    ap_2 = Appropriation(job_id=2,
                         row_number=1,
                         tas=tas_2,
                         budget_authority_unobligat_fyb=None)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap_1,
                                                     ap_2]) == 0

    # Test with split SF133 lines
    tas = 'tas_two_lines'

    sf_1 = SF133(line=1000,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=1,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000',
                 disaster_emergency_fund_code='n')
    sf_2 = SF133(line=1000,
                 tas=tas,
                 period=1,
                 fiscal_year=2016,
                 amount=4,
                 agency_identifier='sys',
                 main_account_code='000',
                 sub_account_code='000',
                 disaster_emergency_fund_code='o')
    ap = Appropriation(job_id=1,
                       row_number=1,
                       tas=tas,
                       budget_authority_unobligat_fyb=5)

    assert number_of_errors(_FILE, database, models=[sf_1, sf_2, ap]) == 0