Beispiel #1
0
def test_success(database):
    """ If both are submitted, AwardingSubTierAgencyCode and AwardingOfficeCode must belong to the same
        AwardingAgencyCode (per the Federal Hierarchy). Ignored if one or both are missing. """

    cgac = CGAC(cgac_id=1, cgac_code='001', agency_name='test')
    frec = FREC(frec_id=1, cgac_id=1, frec_code='0001', agency_name='test2')
    # sub tier codes are different on these offices to prove that we don't care if the office is under that sub tier
    # as long as the top tier codes match
    office_1 = OfficeFactory(office_code='12345a', sub_tier_code='abcd', agency_code=cgac.cgac_code)
    office_2 = OfficeFactory(office_code='123457', sub_tier_code='efgh', agency_code=frec.frec_code)
    agency_1 = SubTierAgency(sub_tier_agency_code='0000', cgac_id=1, frec_id=1, is_frec=False)
    agency_2 = SubTierAgency(sub_tier_agency_code='0001', cgac_id=1, frec_id=1, is_frec=True)

    # Same agency for cgac
    det_award_1 = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
                                                          awarding_office_code=office_1.office_code)
    # Same agency for cgac (uppercased)
    det_award_2 = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
                                                          awarding_office_code=office_1.office_code.upper())
    # Same agency for frec
    det_award_3 = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c=agency_2.sub_tier_agency_code,
                                                          awarding_office_code=office_2.office_code)
    # Missing sub tier code
    det_award_4 = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c='',
                                                          awarding_office_code=office_2.office_code)
    # Missing office code
    det_award_5 = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
                                                          awarding_office_code=None)

    errors = number_of_errors(_FILE, database, models=[cgac, frec, office_1, office_2, agency_1, agency_2, det_award_1,
                                                       det_award_2, det_award_3, det_award_4, det_award_5])
    assert errors == 0
def test_success(database):
    """ Test when provided, FundingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as a Funding Office in the hierarchy.
    """

    office_1 = OfficeFactory(office_code='12345a',
                             contract_funding_office=True,
                             financial_assistance_funding_office=False)
    office_2 = OfficeFactory(office_code='12345b',
                             contract_funding_office=False,
                             financial_assistance_funding_office=True)
    det_award_1 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='12345a')
    # test case insensitive
    det_award_2 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='12345A')
    det_award_3 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='')
    det_award_4 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code=None)
    # Testing second type of funding office
    det_award_5 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='12345b')
    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  office_1, office_2, det_award_1, det_award_2,
                                  det_award_3, det_award_4, det_award_5
                              ])
    assert errors == 0
def test_success_ignore_null_pafa(database):
    """ Test that empty funding office codes aren't matching invalid office codes from the base record. """

    office_1 = OfficeFactory(office_code='12345a', contract_funding_office=True,
                             financial_assistance_funding_office=False)
    office_2 = OfficeFactory(office_code='12345b', contract_funding_office=False,
                             financial_assistance_funding_office=True)
    # Base record has no funding office code, future records don't affect it
    pub_award_1 = PublishedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='zyxwv_123',
                                                           action_date='20181018', award_modification_amendme='0',
                                                           is_active=True)
    pub_award_2 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='zyxwv_123',
                                                           action_date='20181019', award_modification_amendme='1',
                                                           is_active=True)
    # Base record has an invalid code but new record has a funding office entered (ignore this rule)
    pub_award_3 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='abcd_123',
                                                           action_date='20181019', award_modification_amendme='0',
                                                           is_active=True)
    # Base record with a valid office code (case insensitive)
    pub_award_4 = PublishedAwardFinancialAssistanceFactory(funding_office_code='12345A', unique_award_key='1234_abc',
                                                           action_date='20181019', award_modification_amendme='0',
                                                           is_active=True)
    # Earliest record inactive, newer record has valid entry
    pub_award_5 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='4321_cba',
                                                           action_date='20181018', award_modification_amendme='0',
                                                           is_active=False)
    pub_award_6 = PublishedAwardFinancialAssistanceFactory(funding_office_code='12345b', unique_award_key='4321_cba',
                                                           action_date='20181019', award_modification_amendme='1',
                                                           is_active=True)

    # New entry for base award with no office code
    det_award_1 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='zyxwv_123',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    # New entry for base award with invalid code but entry has a funding office code
    det_award_2 = DetachedAwardFinancialAssistanceFactory(funding_office_code='abd', unique_award_key='abcd_123',
                                                          action_date='20181020', award_modification_amendme='1',
                                                          correction_delete_indicatr=None)
    # New entry for valid funding office
    det_award_3 = DetachedAwardFinancialAssistanceFactory(funding_office_code=None, unique_award_key='1234_abc',
                                                          action_date='20181020', award_modification_amendme='1',
                                                          correction_delete_indicatr=None)
    # Correction to base record (ignore)
    det_award_4 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='abcd_123',
                                                          action_date='20181019', award_modification_amendme='0',
                                                          correction_delete_indicatr='C')
    # New entry for earliest inactive
    det_award_5 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='4321_cba',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    errors = number_of_errors(_FILE, database, models=[office_1, office_2, pub_award_1, pub_award_2, pub_award_3,
                                                       pub_award_4, pub_award_5, pub_award_6, det_award_1, det_award_2,
                                                       det_award_3, det_award_4, det_award_5])
    assert errors == 0
Beispiel #4
0
def test_failure(database):
    """ Test fail when provided, AwardingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as an Assistance/Grant Office in the hierarchy.
    """

    office_1 = OfficeFactory(office_code='123456', financial_assistance_awards_office=True)
    office_2 = OfficeFactory(office_code='987654', financial_assistance_awards_office=False)
    fabs_1 = FABSFactory(awarding_office_code='12345', correction_delete_indicatr=None)
    fabs_2 = FABSFactory(awarding_office_code='1234567', correction_delete_indicatr='')
    # Test fail if grant office is false even if code matches
    fabs_3 = FABSFactory(awarding_office_code='987654', correction_delete_indicatr='c')
    errors = number_of_errors(_FILE, database, models=[office_1, office_2, fabs_1, fabs_2, fabs_3])
    assert errors == 3
def test_failure(database):
    """ Test fail that empty funding office codes aren't matching invalid office codes from the base record. """

    office_1 = OfficeFactory(office_code='12345a', contract_funding_office=True,
                             financial_assistance_funding_office=True)
    office_2 = OfficeFactory(office_code='abcd', contract_funding_office=False,
                             financial_assistance_funding_office=False)
    # Invalid code in record
    pub_award_1 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='zyxwv_123',
                                                           action_date='20181018', award_modification_amendme='0',
                                                           is_active=True)
    # Earliest record inactive, newer record has invalid entry
    pub_award_2 = PublishedAwardFinancialAssistanceFactory(funding_office_code='12345a', unique_award_key='4321_cba',
                                                           action_date='20181018', award_modification_amendme='0',
                                                           is_active=False)
    pub_award_3 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='4321_cba',
                                                           action_date='20181019', award_modification_amendme='1',
                                                           is_active=True)
    # Has a valid code but it's not a funding code
    pub_award_4 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abcd', unique_award_key='123_abc',
                                                           action_date='20181018', award_modification_amendme='0',
                                                           is_active=True)
    # award_modification_amendme number is null
    pub_award_5 = PublishedAwardFinancialAssistanceFactory(funding_office_code='abc', unique_award_key='zyxwv_1234',
                                                           action_date='20181018', award_modification_amendme=None,
                                                           is_active=True)

    # Entry for invalid code in base record
    det_award_1 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='zyxwv_123',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    # Entry with award_modification_amendme null
    det_award_2 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='zyxwv_123',
                                                          action_date='20181020', award_modification_amendme=None,
                                                          correction_delete_indicatr=None)
    # New entry for earliest inactive
    det_award_3 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='4321_cba',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    # New entry for has valid non-funding code
    det_award_4 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='123_abc',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    # Entry for award_modification_amendme null in base record
    det_award_5 = DetachedAwardFinancialAssistanceFactory(funding_office_code='', unique_award_key='zyxwv_1234',
                                                          action_date='20181020', award_modification_amendme='2',
                                                          correction_delete_indicatr=None)
    errors = number_of_errors(_FILE, database, models=[office_1, office_2, pub_award_1, pub_award_2, pub_award_3,
                                                       pub_award_4, pub_award_5, det_award_1, det_award_2, det_award_3,
                                                       det_award_4, det_award_5])
    assert errors == 5
def test_success(database):
    """ Test when provided, AwardingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as an Assistance/Grant Office in the hierarchy.
    """

    office = OfficeFactory(office_code='12345a',
                           financial_assistance_awards_office=True)
    det_award_1 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='12345a', correction_delete_indicatr='')
    # test ignore case
    det_award_2 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='12345A', correction_delete_indicatr='c')
    det_award_3 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='', correction_delete_indicatr=None)
    det_award_4 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code=None, correction_delete_indicatr='C')
    # Ignore correction delete indicator of D
    det_award_5 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='12345', correction_delete_indicatr='d')
    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  office, det_award_1, det_award_2,
                                  det_award_3, det_award_4, det_award_5
                              ])
    assert errors == 0
Beispiel #7
0
def test_failure(database):
    """ Test fail when provided, FundingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as a Funding Office in the hierarchy.
    """

    office_1 = OfficeFactory(office_code='123456', funding_office=True)
    office_2 = OfficeFactory(office_code='987654', funding_office=False)
    det_award_1 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='12345')
    det_award_2 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='1234567')
    # Test fail if funding office is false even if code matches
    det_award_3 = DetachedAwardFinancialAssistanceFactory(
        funding_office_code='987654')
    errors = number_of_errors(
        _FILE,
        database,
        models=[office_1, office_2, det_award_1, det_award_2, det_award_3])
    assert errors == 3
def test_success(database):
    """ Test when provided, FundingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as a Funding Office in the hierarchy.
    """

    office_1 = OfficeFactory(office_code='12345a',
                             contract_funding_office=True,
                             financial_assistance_funding_office=False)
    office_2 = OfficeFactory(office_code='12345b',
                             contract_funding_office=False,
                             financial_assistance_funding_office=True)
    fabs_1 = FABSFactory(funding_office_code='12345a',
                         correction_delete_indicatr='')

    # test case insensitive
    fabs_2 = FABSFactory(funding_office_code='12345A',
                         correction_delete_indicatr='c')
    fabs_3 = FABSFactory(funding_office_code='',
                         correction_delete_indicatr=None)
    fabs_4 = FABSFactory(funding_office_code=None,
                         correction_delete_indicatr='C')

    # Testing second type of funding office
    fabs_5 = FABSFactory(funding_office_code='12345b',
                         correction_delete_indicatr='')

    # Ignore correction delete indicator of D
    fabs_6 = FABSFactory(funding_office_code='1234567',
                         correction_delete_indicatr='d')

    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  office_1, office_2, fabs_1, fabs_2, fabs_3,
                                  fabs_4, fabs_5, fabs_6
                              ])
    assert errors == 0
Beispiel #9
0
def test_failure(database):
    """ Test failure if both are submitted, AwardingSubTierAgencyCode and AwardingOfficeCode must belong to the same
        AwardingAgencyCode (per the Federal Hierarchy). """

    cgac = CGAC(cgac_id=1, cgac_code='001', agency_name='test')
    frec = FREC(frec_id=1, cgac_id=1, frec_code='0001', agency_name='test2')
    office = OfficeFactory(office_code='123456', sub_tier_code='abcd', agency_code=cgac.cgac_code)
    agency = SubTierAgency(sub_tier_agency_code='0000', frec_id=1, cgac_id=1, is_frec=True)

    # Sub tier is FREC, office is based on CGAC, the numbers are different
    det_award = DetachedAwardFinancialAssistanceFactory(awarding_sub_tier_agency_c=agency.sub_tier_agency_code,
                                                        awarding_office_code=office.office_code)

    errors = number_of_errors(_FILE, database, models=[det_award, cgac, frec, office, agency])
    assert errors == 1
Beispiel #10
0
def test_success(database):
    """ Test when provided, AwardingOfficeCode must be a valid value from the Federal Hierarchy, including being
        designated specifically as an Assistance/Grant Office in the hierarchy.
    """

    office = OfficeFactory(office_code='12345a', grant_office=True)
    det_award_1 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='12345a')
    # test ignore case
    det_award_2 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='12345A')
    det_award_3 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code='')
    det_award_4 = DetachedAwardFinancialAssistanceFactory(
        awarding_office_code=None)
    errors = number_of_errors(
        _FILE,
        database,
        models=[office, det_award_1, det_award_2, det_award_3, det_award_4])
    assert errors == 0
def test_failure(database):
    """ Test failure if both are submitted, FundingSubTierAgencyCode and FundingOfficeCode must belong to the same
        FundingAgencyCode (per the Federal Hierarchy).
    """
    cgac = CGAC(cgac_id=1, cgac_code='001', agency_name='test')
    frec = FREC(frec_id=1, cgac_id=1, frec_code='0001', agency_name='test2')
    office = OfficeFactory(office_code='123456',
                           sub_tier_code='abcd',
                           agency_code=cgac.cgac_code)
    agency = SubTierAgency(sub_tier_agency_code='0000',
                           frec_id=1,
                           cgac_id=1,
                           is_frec=True)

    # Sub tier is FREC, office is based on CGAC, the numbers are different
    fabs = FABSFactory(funding_sub_tier_agency_co=agency.sub_tier_agency_code,
                       funding_office_code=office.office_code,
                       correction_delete_indicatr='')

    errors = number_of_errors(_FILE,
                              database,
                              models=[fabs, cgac, frec, office, agency])
    assert errors == 1
def test_success(database):
    """ If both are submitted, AwardingSubTierAgencyCode and AwardingOfficeCode must belong to the same
        AwardingAgencyCode (per the Federal Hierarchy). Ignored if one or both are missing.
    """
    cgac = CGAC(cgac_id=1, cgac_code='001', agency_name='test')
    frec = FREC(frec_id=1, cgac_id=1, frec_code='0001', agency_name='test2')
    # sub tier codes are different on these offices to prove that we don't care if the office is under that sub tier
    # as long as the top tier codes match
    office_1 = OfficeFactory(office_code='12345a',
                             sub_tier_code='abcd',
                             agency_code=cgac.cgac_code)
    office_2 = OfficeFactory(office_code='123457',
                             sub_tier_code='efgh',
                             agency_code=frec.frec_code)
    agency_1 = SubTierAgency(sub_tier_agency_code='a000',
                             cgac_id=1,
                             frec_id=1,
                             is_frec=False)
    agency_2 = SubTierAgency(sub_tier_agency_code='0001',
                             cgac_id=1,
                             frec_id=1,
                             is_frec=True)

    # Same agency for cgac
    fabs_1 = FABSFactory(
        awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
        awarding_office_code=office_1.office_code,
        correction_delete_indicatr='')
    # Same agency for cgac (uppercased)
    fabs_2 = FABSFactory(
        awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code.upper(),
        awarding_office_code=office_1.office_code.upper(),
        correction_delete_indicatr=None)
    # Same agency for frec
    fabs_3 = FABSFactory(
        awarding_sub_tier_agency_c=agency_2.sub_tier_agency_code,
        awarding_office_code=office_2.office_code,
        correction_delete_indicatr='c')
    # Missing sub tier code
    fabs_4 = FABSFactory(awarding_sub_tier_agency_c='',
                         awarding_office_code=office_2.office_code,
                         correction_delete_indicatr='C')
    # Missing office code
    fabs_5 = FABSFactory(
        awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
        awarding_office_code=None,
        correction_delete_indicatr='')
    # Ignore correction delete indicator of D
    fabs_6 = FABSFactory(
        awarding_sub_tier_agency_c=agency_1.sub_tier_agency_code,
        awarding_office_code=office_2.office_code,
        correction_delete_indicatr='d')

    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  cgac, frec, office_1, office_2, agency_1,
                                  agency_2, fabs_1, fabs_2, fabs_3, fabs_4,
                                  fabs_5, fabs_6
                              ])
    assert errors == 0
Beispiel #13
0
def test_success_ignore_null_pub_fabs(database):
    """ Test that empty awarding office codes aren't matching invalid office codes from the base record. """

    office = OfficeFactory(office_code='12345a',
                           financial_assistance_awards_office=True)
    # Base record has no awarding office code, future records don't affect it
    pub_fabs_1 = PublishedFABSFactory(awarding_office_code='',
                                      unique_award_key='zyxwv_123',
                                      action_date='20181018',
                                      award_modification_amendme='0',
                                      is_active=True)
    pub_fabs_2 = PublishedFABSFactory(awarding_office_code='abc',
                                      unique_award_key='zyxwv_123',
                                      action_date='20181019',
                                      award_modification_amendme='1',
                                      is_active=True)
    # Base record has an invalid code but new record has a awarding office entered (ignore this rule)
    pub_fabs_3 = PublishedFABSFactory(awarding_office_code='abc',
                                      unique_award_key='abcd_123',
                                      action_date='20181019',
                                      award_modification_amendme='0',
                                      is_active=True)
    # Base record with a valid office code (case insensitive)
    pub_fabs_4 = PublishedFABSFactory(awarding_office_code='12345A',
                                      unique_award_key='1234_abc',
                                      action_date='20181019',
                                      award_modification_amendme='0',
                                      is_active=True)
    # Earliest record inactive, newer record has valid entry, inactive date matching active doesn't mess it up
    pub_fabs_5 = PublishedFABSFactory(awarding_office_code='abc',
                                      unique_award_key='4321_cba',
                                      action_date='20181018',
                                      award_modification_amendme='0',
                                      is_active=False)
    pub_fabs_6 = PublishedFABSFactory(awarding_office_code='abc',
                                      unique_award_key='4321_cba',
                                      action_date='20181019',
                                      award_modification_amendme='1',
                                      is_active=False)
    pub_fabs_7 = PublishedFABSFactory(awarding_office_code='12345a',
                                      unique_award_key='4321_cba',
                                      action_date='20181019',
                                      award_modification_amendme='1',
                                      is_active=True)

    # New entry for base award with no office code
    fabs_1 = FABSFactory(awarding_office_code='',
                         unique_award_key='zyxwv_123',
                         action_date='20181020',
                         award_modification_amendme='2',
                         correction_delete_indicatr=None)
    # New entry for base award with invalid code but entry has a awarding office code
    fabs_2 = FABSFactory(awarding_office_code='abd',
                         unique_award_key='abcd_123',
                         action_date='20181020',
                         award_modification_amendme='1',
                         correction_delete_indicatr=None)
    # New entry for valid awarding office
    fabs_3 = FABSFactory(awarding_office_code=None,
                         unique_award_key='1234_abc',
                         action_date='20181020',
                         award_modification_amendme='1',
                         correction_delete_indicatr=None)
    # Correction to base record (ignore)
    fabs_4 = FABSFactory(awarding_office_code='',
                         unique_award_key='abcd_123',
                         action_date='20181019',
                         award_modification_amendme='0',
                         correction_delete_indicatr='C')
    # New entry for earliest inactive
    fabs_5 = FABSFactory(awarding_office_code='',
                         unique_award_key='4321_cba',
                         action_date='20181020',
                         award_modification_amendme='2',
                         correction_delete_indicatr=None)
    errors = number_of_errors(_FILE,
                              database,
                              models=[
                                  office, pub_fabs_1, pub_fabs_2, pub_fabs_3,
                                  pub_fabs_4, pub_fabs_5, pub_fabs_6,
                                  pub_fabs_7, fabs_1, fabs_2, fabs_3, fabs_4,
                                  fabs_5
                              ])
    assert errors == 0