-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3584 from GSA-TTS/main
- Loading branch information
Showing
26 changed files
with
889 additions
and
1,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
MAX_EXCEL_FILE_SIZE_MB, | ||
validate_additional_ueis_json, | ||
validate_additional_eins_json, | ||
validate_general_information_schema, | ||
validate_general_information_schema_rules, | ||
validate_notes_to_sefa_json, | ||
validate_corrective_action_plan_json, | ||
validate_file_content_type, | ||
|
@@ -994,3 +996,177 @@ def test_error_is_not_gsa_migration_auditor_email(self): | |
|
||
with self.assertRaises(ValidationError): | ||
validate_general_information_json(gen_info, False) | ||
|
||
|
||
class TestValidateGeneralInformation(SimpleTestCase): | ||
def setUp(self): | ||
"""Set up common test data""" | ||
# Example general information that matches the schema | ||
self.valid_general_information = { | ||
"audit_period_covered": "annual", | ||
"auditor_country": "USA", | ||
"ein": "123456789", | ||
"audit_type": "single-audit", | ||
"auditee_uei": "AQDDHJH47DW7", | ||
"auditee_zip": "12345", | ||
"auditor_ein": "123456789", | ||
"auditor_zip": "12345", | ||
"auditee_city": "Washington", | ||
"auditee_name": "Auditee Name", | ||
"auditor_city": "Washington", | ||
"is_usa_based": True, | ||
"auditee_email": "[email protected]", | ||
"auditee_phone": "1234567890", | ||
"auditee_state": "DC", | ||
"auditor_email": "[email protected]", | ||
"auditor_phone": "1234567890", | ||
"auditor_state": "DC", | ||
"auditor_country": "USA", | ||
"auditor_firm_name": "Auditor Firm Name", | ||
"audit_period_covered": "annual", | ||
"auditee_contact_name": "Auditee Contact Name", | ||
"auditor_contact_name": "Auditor Contact Name", | ||
"auditee_contact_title": "Auditee Contact Title", | ||
"auditor_contact_title": "Auditor Contact Title", | ||
"multiple_eins_covered": False, | ||
"multiple_ueis_covered": False, | ||
"auditee_address_line_1": "Auditee Address Line 1", | ||
"auditor_address_line_1": "Auditor Address Line 1", | ||
"met_spending_threshold": True, | ||
"secondary_auditors_exist": False, | ||
"audit_period_other_months": "", | ||
"auditee_fiscal_period_end": "2023-12-31", | ||
"ein_not_an_ssn_attestation": False, | ||
"auditee_fiscal_period_start": "2023-01-01", | ||
"auditor_international_address": "", | ||
"user_provided_organization_type": "state", | ||
"auditor_ein_not_an_ssn_attestation": False, | ||
} | ||
|
||
self.invalid_fiscal_period_end = self.valid_general_information | { | ||
"auditee_fiscal_period_end": "Not a date", | ||
} | ||
|
||
self.wrong_fiscal_period_end_format = self.valid_general_information | { | ||
"auditee_fiscal_period_end": "2023-31-12", | ||
} | ||
|
||
self.invalid_auditee_uei = self.valid_general_information | { | ||
"auditee_uei": "Invalid", | ||
} | ||
|
||
self.invalid_audit_period_other_months = self.valid_general_information | { | ||
"audit_period_other_months": "Invalid", | ||
} | ||
|
||
self.unexpected_state_and_zip = self.valid_general_information | { | ||
"auditor_state": "DC", | ||
"auditor_zip": "12345", | ||
"auditor_country": "", | ||
} | ||
|
||
self.unexpected_audit_period_other_months = self.valid_general_information | { | ||
"audit_period_covered": "annual", | ||
"audit_period_other_months": "12", | ||
} | ||
|
||
self.missing_audit_period_other_months = self.valid_general_information | { | ||
"audit_period_covered": "other", | ||
"audit_period_other_months": "", | ||
} | ||
|
||
self.missing_state_and_zip = self.valid_general_information | { | ||
"auditor_state": "", | ||
"auditor_zip": "", | ||
"auditee_country": "USA", | ||
} | ||
|
||
self.invalid_state_and_zip = self.valid_general_information | { | ||
"auditor_state": "Not a state", | ||
"auditor_zip": "Not a zip", | ||
} | ||
|
||
self.invalid_phone = self.valid_general_information | { | ||
"auditor_phone": "123-456-789", | ||
} | ||
|
||
self.invalid_email = self.valid_general_information | { | ||
"auditor_email": "auditor.email.com", | ||
} | ||
|
||
self.invalid_audit_period_covered = self.valid_general_information | { | ||
"audit_period_covered": "Invalid", | ||
} | ||
|
||
def test_validate_general_information_schema_with_valid_data(self): | ||
""" | ||
Test the validation method with valid general information data. | ||
""" | ||
try: | ||
validate_general_information_schema(self.valid_general_information) | ||
except ValidationError: | ||
self.fail( | ||
"validate_general_information_schema raised ValidationError unexpectedly!" | ||
) | ||
|
||
def test_validate_general_information_schema_with_invalid_data(self): | ||
""" | ||
Test the validation method with invalid general information data. | ||
""" | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_fiscal_period_end) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.wrong_fiscal_period_end_format) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_auditee_uei) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_audit_period_other_months) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_state_and_zip) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_phone) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_email) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema(self.invalid_audit_period_covered) | ||
|
||
def test_validate_general_information_schema_rules_with_valid_data(self): | ||
""" | ||
Test the validation method with valid general information data. | ||
""" | ||
try: | ||
validate_general_information_schema_rules(self.valid_general_information) | ||
except ValidationError: | ||
self.fail( | ||
"validate_general_information_schema_rules raised ValidationError unexpectedly!" | ||
) | ||
|
||
def test_validate_general_information_schema_rules_with_invalid_data(self): | ||
""" | ||
Test the validation method with invalid general information data. | ||
""" | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema_rules(self.unexpected_state_and_zip) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema_rules( | ||
self.unexpected_audit_period_other_months | ||
) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema_rules( | ||
self.missing_audit_period_other_months | ||
) | ||
with self.assertRaises(ValidationError): | ||
validate_general_information_schema_rules(self.missing_state_and_zip) | ||
|
||
def tes_validate_general_information_json(self): | ||
""" | ||
Test the validation method with valid general information data. | ||
""" | ||
try: | ||
validate_general_information_json( | ||
self.valid_general_information, is_data_migration=False | ||
) | ||
except ValidationError: | ||
self.fail( | ||
"validate_general_information_json raised ValidationError unexpectedly!" | ||
) |
Oops, something went wrong.