Skip to content

Commit

Permalink
Merge pull request #3258 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Jan 23, 2024
2 parents dbe42c9 + 60d1b1e commit ea96c70
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-dev-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: null

jobs:
trivy-scan:
dev-media-snapshot:
uses: ./.github/workflows/tar-s3-media.yml
secrets: inherit
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-dev-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: null

jobs:
trivy-scan:
dev-media-sync:
uses: ./.github/workflows/sync-s3-media.yml
secrets: inherit
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-production-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: null

jobs:
trivy-scan:
production-media-snapshot:
uses: ./.github/workflows/tar-s3-media.yml
secrets: inherit
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-production-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch: null

jobs:
trivy-scan:
production-media-sync:
uses: ./.github/workflows/sync-s3-media.yml
secrets: inherit
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
xform_country,
xform_entity_type,
xform_replace_empty_auditor_email,
xform_replace_empty_auditee_email,
)
from .exception_utils import (
DataMigrationError,
Expand Down Expand Up @@ -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": "[email protected]"}
expected_output = {"auditee_email": "[email protected]"}
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)
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@
"auditee_email": {
"oneOf": [
{
"format": "email"
"format": "email",
"maxLength": 100,
"type": "string"
},
{
"const": "GSA_MIGRATION",
"type": "string"
},
{
"const": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@
"auditee_email": {
"oneOf": [
{
"format": "email"
"format": "email",
"maxLength": 100,
"type": "string"
},
{
"const": "GSA_MIGRATION",
"type": "string"
},
{
"const": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea96c70

Please sign in to comment.