From 31b3cbc78547096f5263c4c91b1a2b24b97aa73b Mon Sep 17 00:00:00 2001 From: Alex Steel <130377221+asteel-gsa@users.noreply.github.com> Date: Mon, 22 Jan 2024 08:47:24 -0500 Subject: [PATCH 1/2] Fix Job Names (#3199) --- .github/workflows/scheduled-dev-snapshot.yml | 2 +- .github/workflows/scheduled-dev-sync.yml | 2 +- .github/workflows/scheduled-production-snapshot.yml | 2 +- .github/workflows/scheduled-production-sync.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scheduled-dev-snapshot.yml b/.github/workflows/scheduled-dev-snapshot.yml index 5fb62d9eec..993d729766 100644 --- a/.github/workflows/scheduled-dev-snapshot.yml +++ b/.github/workflows/scheduled-dev-snapshot.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: null jobs: - trivy-scan: + dev-media-snapshot: uses: ./.github/workflows/tar-s3-media.yml secrets: inherit with: diff --git a/.github/workflows/scheduled-dev-sync.yml b/.github/workflows/scheduled-dev-sync.yml index 6139bff886..01725a2e6c 100644 --- a/.github/workflows/scheduled-dev-sync.yml +++ b/.github/workflows/scheduled-dev-sync.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: null jobs: - trivy-scan: + dev-media-sync: uses: ./.github/workflows/sync-s3-media.yml secrets: inherit with: diff --git a/.github/workflows/scheduled-production-snapshot.yml b/.github/workflows/scheduled-production-snapshot.yml index fb5a68f3f4..f73e826c8f 100644 --- a/.github/workflows/scheduled-production-snapshot.yml +++ b/.github/workflows/scheduled-production-snapshot.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: null jobs: - trivy-scan: + production-media-snapshot: uses: ./.github/workflows/tar-s3-media.yml secrets: inherit with: diff --git a/.github/workflows/scheduled-production-sync.yml b/.github/workflows/scheduled-production-sync.yml index b953be0fdd..15586124d3 100644 --- a/.github/workflows/scheduled-production-sync.yml +++ b/.github/workflows/scheduled-production-sync.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: null jobs: - trivy-scan: + production-media-sync: uses: ./.github/workflows/sync-s3-media.yml secrets: inherit with: From 60d1b1ea6b9bf9c92be49a99c6c63d38eb350e56 Mon Sep 17 00:00:00 2001 From: Phil Dominguez <142051477+phildominguez-gsa@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:08:03 -0500 Subject: [PATCH 2/2] Census migration: Handling empty `auditee_email`s (#3255) * Handling empty auditee_emails * Adding unit tests * Removing wbs added by mistake * Ran build_sections --- .../sac_general_lib/general_information.py | 16 ++++++++++++++ .../test_general_information_xforms.py | 21 +++++++++++++++++++ .../sections/GeneralInformation.schema.json | 8 ++++++- .../GeneralInformationComplete.schema.json | 16 ++++++++++---- .../GeneralInformationRequired.schema.json | 8 ++++++- .../GeneralInformation.schema.jsonnet | 6 +++++- .../GeneralInformationComplete.schema.jsonnet | 15 +++++++++---- 7 files changed, 79 insertions(+), 11 deletions(-) diff --git a/backend/census_historical_migration/sac_general_lib/general_information.py b/backend/census_historical_migration/sac_general_lib/general_information.py index ed9aae4330..a96a392e1a 100644 --- a/backend/census_historical_migration/sac_general_lib/general_information.py +++ b/backend/census_historical_migration/sac_general_lib/general_information.py @@ -305,6 +305,21 @@ def xform_replace_empty_auditor_email(general_information): return general_information +def xform_replace_empty_auditee_email(general_information): + """Replaces empty auditee email with GSA Migration keyword""" + # Transformation recorded. + if not general_information.get("auditee_email"): + general_information["auditee_email"] = settings.GSA_MIGRATION + track_transformations( + "AUDITEEEMAIL", + "", + "auditee_email", + general_information["auditee_email"], + "xform_replace_empty_auditee_email", + ) + return general_information + + def track_transformations( census_column, census_value, gsa_field, gsa_value, transformation_functions ): @@ -333,6 +348,7 @@ def general_information(audit_header): xform_audit_period_covered, xform_audit_type, xform_replace_empty_auditor_email, + xform_replace_empty_auditee_email, ] for transform in transformations: diff --git a/backend/census_historical_migration/test_general_information_xforms.py b/backend/census_historical_migration/test_general_information_xforms.py index 24230a4a23..4ffb49a4d9 100644 --- a/backend/census_historical_migration/test_general_information_xforms.py +++ b/backend/census_historical_migration/test_general_information_xforms.py @@ -12,6 +12,7 @@ xform_country, xform_entity_type, xform_replace_empty_auditor_email, + xform_replace_empty_auditee_email, ) from .exception_utils import ( DataMigrationError, @@ -240,3 +241,23 @@ def test_missing_auditor_email(self): input_data = {} expected_output = {"auditor_email": settings.GSA_MIGRATION} self.assertEqual(xform_replace_empty_auditor_email(input_data), expected_output) + + +class TestXformReplaceEmptyAuditeeEmail(SimpleTestCase): + def test_empty_auditee_email(self): + """Test that an empty auditee_email is replaced with 'GSA_MIGRATION'""" + input_data = {"auditee_email": ""} + expected_output = {"auditee_email": settings.GSA_MIGRATION} + self.assertEqual(xform_replace_empty_auditee_email(input_data), expected_output) + + def test_non_empty_auditee_email(self): + """Test that a non-empty auditee_email remains unchanged""" + input_data = {"auditee_email": "test@example.com"} + expected_output = {"auditee_email": "test@example.com"} + self.assertEqual(xform_replace_empty_auditee_email(input_data), expected_output) + + def test_missing_auditee_email(self): + """Test that a missing auditee_email key is added and set to 'GSA_MIGRATION'""" + input_data = {} + expected_output = {"auditee_email": settings.GSA_MIGRATION} + self.assertEqual(xform_replace_empty_auditee_email(input_data), expected_output) diff --git a/backend/schemas/output/sections/GeneralInformation.schema.json b/backend/schemas/output/sections/GeneralInformation.schema.json index 638ee0d886..9525fae7dc 100644 --- a/backend/schemas/output/sections/GeneralInformation.schema.json +++ b/backend/schemas/output/sections/GeneralInformation.schema.json @@ -241,7 +241,13 @@ "auditee_email": { "oneOf": [ { - "format": "email" + "format": "email", + "maxLength": 100, + "type": "string" + }, + { + "const": "GSA_MIGRATION", + "type": "string" }, { "const": "", diff --git a/backend/schemas/output/sections/GeneralInformationComplete.schema.json b/backend/schemas/output/sections/GeneralInformationComplete.schema.json index b068e6e571..d22cf65b49 100644 --- a/backend/schemas/output/sections/GeneralInformationComplete.schema.json +++ b/backend/schemas/output/sections/GeneralInformationComplete.schema.json @@ -156,10 +156,18 @@ "type": "string" }, "auditee_email": { - "format": "email", - "maxLength": 100, - "minLength": 1, - "type": "string" + "oneOf": [ + { + "format": "email", + "maxLength": 100, + "minLength": 1, + "type": "string" + }, + { + "const": "GSA_MIGRATION", + "type": "string" + } + ] }, "auditee_fiscal_period_end": { "format": "date" diff --git a/backend/schemas/output/sections/GeneralInformationRequired.schema.json b/backend/schemas/output/sections/GeneralInformationRequired.schema.json index ffe67fe813..3616cde650 100644 --- a/backend/schemas/output/sections/GeneralInformationRequired.schema.json +++ b/backend/schemas/output/sections/GeneralInformationRequired.schema.json @@ -241,7 +241,13 @@ "auditee_email": { "oneOf": [ { - "format": "email" + "format": "email", + "maxLength": 100, + "type": "string" + }, + { + "const": "GSA_MIGRATION", + "type": "string" }, { "const": "", diff --git a/backend/schemas/source/sections/GeneralInformation.schema.jsonnet b/backend/schemas/source/sections/GeneralInformation.schema.jsonnet index 2e3a657540..b94682806e 100644 --- a/backend/schemas/source/sections/GeneralInformation.schema.jsonnet +++ b/backend/schemas/source/sections/GeneralInformation.schema.jsonnet @@ -91,8 +91,12 @@ Typechecks fields, but allows for empty data as well. Contains conditional Check }, auditee_email: Types.string { oneOf: [ - { + Types.string { format: 'email', + maxLength: 100, + }, + Types.string { + const: Base.Const.GSA_MIGRATION, }, Base.Compound.EmptyString, ], diff --git a/backend/schemas/source/sections/GeneralInformationComplete.schema.jsonnet b/backend/schemas/source/sections/GeneralInformationComplete.schema.jsonnet index eb976e4375..9064f1f735 100644 --- a/backend/schemas/source/sections/GeneralInformationComplete.schema.jsonnet +++ b/backend/schemas/source/sections/GeneralInformationComplete.schema.jsonnet @@ -53,10 +53,17 @@ Requires most fields, has consitional checks for conditional fields. minLength: 1, }, auditee_phone: Base.Compound.UnitedStatesPhone, - auditee_email: Types.string { - format: 'email', - maxLength: 100, - minLength: 1, + auditee_email: { + oneOf: [ + Types.string { + format: 'email', + maxLength: 100, + minLength: 1, + }, + Types.string { + const: Base.Const.GSA_MIGRATION, + }, + ], }, // Auditor information