def cross_file_warnings(self):
    self.cleanup()
    (report_headers, report_content) = self.generate_cross_file_report([(CROSS_FILE_A, 'appropriations'), (CROSS_FILE_B, 'program_activity')], warning=True)
    error_count = self.session.query(ErrorMetadata).filter_by(job_id=self.val_job.job_id, severity_id=RULE_SEVERITY_DICT['warning']).count()
    assert (error_count == 0)
    assert (report_headers == self.validator.cross_file_report_headers)
    assert (len(report_content) == 0)
    self.cleanup()
    (report_headers, report_content) = self.generate_cross_file_report([(INVALID_CROSS_A, 'appropriations'), (INVALID_CROSS_B, 'program_activity')], warning=True)
    warnings = list(self.session.query(ErrorMetadata).filter_by(job_id=self.val_job.job_id, severity_id=RULE_SEVERITY_DICT['warning']).all())
    assert (len(warnings) == 3)
    assert (warnings[0].occurrences == 3)
    assert (warnings[1].occurrences == 3)
    assert (warnings[2].occurrences == 3)
    assert (report_headers == self.validator.cross_file_report_headers)
    expected_values = [{'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A35'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A35'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A35'}]
    assert (report_content == expected_values)
    self.cleanup()
def cross_file_warnings(self):
    self.cleanup()
    (report_headers, report_content) = self.generate_cross_file_report([(CROSS_FILE_A, 'appropriations'), (CROSS_FILE_B, 'program_activity')], warning=True)
    error_count = self.session.query(ErrorMetadata).filter_by(job_id=self.val_job.job_id, severity_id=RULE_SEVERITY_DICT['warning']).count()
    assert (error_count == 0)
    assert (report_headers == self.validator.cross_file_report_headers)
    assert (len(report_content) == 0)
    self.cleanup()
    (report_headers, report_content) = self.generate_cross_file_report([(INVALID_CROSS_A, 'appropriations'), (INVALID_CROSS_B, 'program_activity')], warning=True)
    warnings = list(self.session.query(ErrorMetadata).filter_by(job_id=self.val_job.job_id, severity_id=RULE_SEVERITY_DICT['warning']).all())
    assert (len(warnings) == 3)
    assert (warnings[0].occurrences == 3)
    assert (warnings[1].occurrences == 3)
    assert (warnings[2].occurrences == 3)
    assert (report_headers == self.validator.cross_file_report_headers)
    expected_values = [{'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '5', 'Rule Label': 'A35'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '10', 'Rule Label': 'A35'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'grossoutlayamountbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'gross_outlay_amount_by_pro_cpe_sum', 'Rule Message': 'The GrossOutlayAmountByTAS_CPE amount in the appropriation file (A) does not equal the sum of the corresponding GrossOutlayAmountByProgramObjectClass_CPE values in the award financial file (B). {This value is the sum of all Gross Outlay Amounts reported in file B, to indicate year-to-date activity by TAS/Subaccount.}', 'Source Value Provided': 'grossoutlayamountbytas_cpe: 10000', 'Target Value Provided': 'gross_outlay_amount_by_pro_cpe_sum: 6000', 'Difference': '4000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A18'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'obligationsincurredtotalbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'obligations_incurred_by_pr_cpe_sum', 'Rule Message': 'The ObligationsIncurredTotalByTAS_CPE amount in the appropriation file (A) does not equal the negative sum of the corresponding ObligationsIncurredByProgramObjectClass_CPE values in the award financial file (B).', 'Source Value Provided': 'obligationsincurredtotalbytas_cpe: 12000', 'Target Value Provided': 'obligations_incurred_by_pr_cpe_sum: 6000', 'Difference': '18000', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A19'}, {'Unique ID': 'TAS: 019-2016/2016-0113-000', 'Source File': 'appropriations', 'Source Field Name': 'deobligationsrecoveriesrefundsbytas_cpe', 'Target File': 'program_activity', 'Target Field Name': 'ussgl487100_downward_adjus_cpe_sum, ussgl497100_downward_adjus_cpe_sum, ussgl487200_downward_adjus_cpe_sum, ussgl497200_downward_adjus_cpe_sum', 'Rule Message': 'DeobligationsRecoveriesRefundsByTAS_CPE in File A should equal USSGL (4871_CPE+ 4971_CPE+ 4872_CPE+ 4972_CPE) for the TAS in File B.', 'Source Value Provided': 'deobligationsrecoveriesrefundsbytas_cpe: 16000', 'Target Value Provided': 'ussgl487100_downward_adjus_cpe_sum: 2000, ussgl497100_downward_adjus_cpe_sum: 2000, ussgl487200_downward_adjus_cpe_sum: 400, ussgl497200_downward_adjus_cpe_sum: 2000', 'Difference': '9600', 'Source Flex Field': 'flex_field_a: FLEX_A, flex_field_b: FLEX_B', 'Source Row Number': '15', 'Rule Label': 'A35'}]
    assert (report_content == expected_values)
    self.cleanup()