mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-31 01:33:56 +02:00
Finish test / Add debug flag
This commit is contained in:
parent
44c7631eaa
commit
f7d906245e
2 changed files with 122 additions and 19 deletions
|
@ -136,7 +136,7 @@ class LoadExtraTransitionDomain:
|
||||||
def __init__(self, options: TransitionDomainArguments):
|
def __init__(self, options: TransitionDomainArguments):
|
||||||
# Globally stores event logs and organizes them
|
# Globally stores event logs and organizes them
|
||||||
self.parse_logs = FileTransitionLog()
|
self.parse_logs = FileTransitionLog()
|
||||||
print(f"options correct? {options.agency_adhoc_filename}")
|
self.debug = options.debug
|
||||||
# Reads and parses migration files
|
# Reads and parses migration files
|
||||||
self.parsed_data_container = ExtraTransitionDomain(options)
|
self.parsed_data_container = ExtraTransitionDomain(options)
|
||||||
self.parsed_data_container.parse_all_files(options.infer_filenames)
|
self.parsed_data_container.parse_all_files(options.infer_filenames)
|
||||||
|
@ -178,8 +178,9 @@ class LoadExtraTransitionDomain:
|
||||||
#if updated_transition_domain.__dict__ != transition_domain.__dict__:
|
#if updated_transition_domain.__dict__ != transition_domain.__dict__:
|
||||||
updated_transition_domain.save()
|
updated_transition_domain.save()
|
||||||
updated_transition_domains.append(updated_transition_domain)
|
updated_transition_domains.append(updated_transition_domain)
|
||||||
|
if self.debug:
|
||||||
self.parse_logs.display_logs_by_domain_name(domain_name)
|
# Display errors for this specific domain
|
||||||
|
self.parse_logs.display_logs_by_domain_name(domain_name)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{TerminalColors.OKCYAN}"
|
f"{TerminalColors.OKCYAN}"
|
||||||
f"Successfully updated {domain_name}"
|
f"Successfully updated {domain_name}"
|
||||||
|
@ -198,6 +199,10 @@ class LoadExtraTransitionDomain:
|
||||||
)
|
)
|
||||||
failed_transition_domains.append(domain_name)
|
failed_transition_domains.append(domain_name)
|
||||||
|
|
||||||
|
if self.debug:
|
||||||
|
# Display misc errors (not associated to a domain)
|
||||||
|
self.parse_logs.display_logs_by_domain_name(None)
|
||||||
|
|
||||||
failed_count = len(failed_transition_domains)
|
failed_count = len(failed_transition_domains)
|
||||||
if failed_count == 0:
|
if failed_count == 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
@ -168,7 +168,7 @@ class TestMigrations(TestCase):
|
||||||
|
|
||||||
# STEP 2: (analyze the tables just like the
|
# STEP 2: (analyze the tables just like the
|
||||||
# migration script does, but add assert statements)
|
# migration script does, but add assert statements)
|
||||||
expected_total_transition_domains = 8
|
expected_total_transition_domains = 9
|
||||||
expected_total_domains = 4
|
expected_total_domains = 4
|
||||||
expected_total_domain_informations = 4
|
expected_total_domain_informations = 4
|
||||||
expected_total_domain_invitations = 7
|
expected_total_domain_invitations = 7
|
||||||
|
@ -195,7 +195,7 @@ class TestMigrations(TestCase):
|
||||||
|
|
||||||
# STEP 2: (analyze the tables just like the migration
|
# STEP 2: (analyze the tables just like the migration
|
||||||
# script does, but add assert statements)
|
# script does, but add assert statements)
|
||||||
expected_total_transition_domains = 8
|
expected_total_transition_domains = 9
|
||||||
expected_total_domains = 0
|
expected_total_domains = 0
|
||||||
expected_total_domain_informations = 0
|
expected_total_domain_informations = 0
|
||||||
expected_total_domain_invitations = 0
|
expected_total_domain_invitations = 0
|
||||||
|
@ -221,15 +221,15 @@ class TestMigrations(TestCase):
|
||||||
|
|
||||||
# We should get a consistent number
|
# We should get a consistent number
|
||||||
# of records
|
# of records
|
||||||
expected_total_transition_domains = 8
|
expected_total_transition_domains = 9
|
||||||
expected_total_domains = 0
|
expected_total_domains = 0
|
||||||
expected_total_domain_informations = 0
|
expected_total_domain_informations = 0
|
||||||
expected_total_domain_invitations = 0
|
expected_total_domain_invitations = 0
|
||||||
|
|
||||||
expected_missing_domains = 8
|
expected_missing_domains = 9
|
||||||
expected_duplicate_domains = 0
|
expected_duplicate_domains = 0
|
||||||
expected_missing_domain_informations = 8
|
expected_missing_domain_informations = 9
|
||||||
expected_missing_domain_invitations = 8
|
expected_missing_domain_invitations = 9
|
||||||
self.compare_tables(
|
self.compare_tables(
|
||||||
expected_total_transition_domains,
|
expected_total_transition_domains,
|
||||||
expected_total_domains,
|
expected_total_domains,
|
||||||
|
@ -247,27 +247,125 @@ class TestMigrations(TestCase):
|
||||||
domain_name="anomaly.gov",
|
domain_name="anomaly.gov",
|
||||||
status="ready",
|
status="ready",
|
||||||
email_sent=False,
|
email_sent=False,
|
||||||
organization_type="None",
|
organization_type=None,
|
||||||
organization_name="Flashdog",
|
organization_name="Flashdog",
|
||||||
federal_type="None",
|
federal_type=None,
|
||||||
federal_agency="None",
|
federal_agency=None,
|
||||||
epp_creation_date=None,
|
epp_creation_date=None,
|
||||||
epp_expiration_date=None
|
epp_expiration_date=None
|
||||||
),
|
),
|
||||||
TransitionDomain(
|
TransitionDomain(
|
||||||
username="",
|
username="testuser@gmail.com",
|
||||||
domain_name="anomaly.gov",
|
domain_name="testdomain.gov",
|
||||||
status="ready",
|
status="ready",
|
||||||
email_sent=False,
|
email_sent=False,
|
||||||
organization_type="None",
|
organization_type=None,
|
||||||
organization_name="Flashdog",
|
organization_name="Gigaclub",
|
||||||
federal_type="None",
|
federal_type=None,
|
||||||
federal_agency="None",
|
federal_agency=None,
|
||||||
epp_creation_date=None,
|
epp_creation_date=None,
|
||||||
epp_expiration_date=None
|
epp_expiration_date=None
|
||||||
),
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="agustina.wyman7@test.com",
|
||||||
|
domain_name="fakewebsite1.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type=None,
|
||||||
|
organization_name="Midel",
|
||||||
|
federal_type=None,
|
||||||
|
federal_agency=None,
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="susy.martin4@test.com",
|
||||||
|
domain_name="fakewebsite1.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type=None,
|
||||||
|
organization_name="Midel",
|
||||||
|
federal_type=None,
|
||||||
|
federal_agency=None,
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="stephania.winters4@test.com",
|
||||||
|
domain_name="fakewebsite1.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type=None,
|
||||||
|
organization_name="Midel",
|
||||||
|
federal_type=None,
|
||||||
|
federal_agency=None,
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="alexandra.bobbitt5@test.com",
|
||||||
|
domain_name="fakewebsite2.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type="Federal",
|
||||||
|
organization_name="Fanoodle",
|
||||||
|
federal_type="Executive",
|
||||||
|
federal_agency="InnoZ",
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="jospeh.mcdowell3@test.com",
|
||||||
|
domain_name="fakewebsite2.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type="Federal",
|
||||||
|
organization_name="Fanoodle",
|
||||||
|
federal_type="Executive",
|
||||||
|
federal_agency="InnoZ",
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="reginald.ratcliff4@test.com",
|
||||||
|
domain_name="fakewebsite2.gov",
|
||||||
|
status="on hold",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type="Federal",
|
||||||
|
organization_name="Fanoodle",
|
||||||
|
federal_type="Executive",
|
||||||
|
federal_agency="InnoZ",
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
),
|
||||||
|
TransitionDomain(
|
||||||
|
username="reginald.ratcliff4@test.com",
|
||||||
|
domain_name="fakewebsite3.gov",
|
||||||
|
status="ready",
|
||||||
|
email_sent=False,
|
||||||
|
organization_type="City",
|
||||||
|
organization_name="Sushi",
|
||||||
|
federal_type=None,
|
||||||
|
federal_agency=None,
|
||||||
|
epp_creation_date=None,
|
||||||
|
epp_expiration_date=None
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Afterwards, their values should be what we expect
|
# Afterwards, their values should be what we expect
|
||||||
|
all_transition_domains = TransitionDomain.objects.all()
|
||||||
|
for domain in all_transition_domains:
|
||||||
|
for expected in expected_transition_domains:
|
||||||
|
|
||||||
|
# This data gets created when the object is,
|
||||||
|
# so we should just match it. Not relevant
|
||||||
|
# to the added data.
|
||||||
|
expected.id = domain.id
|
||||||
|
expected.created_at = domain.created_at
|
||||||
|
expected.updated_at = domain.updated_at
|
||||||
|
|
||||||
|
# Each TransitionDomain should have the correct data
|
||||||
|
self.assertEqual(domain, expected)
|
||||||
|
|
||||||
def test_transfer_transition_domains_to_domains(self):
|
def test_transfer_transition_domains_to_domains(self):
|
||||||
# TODO: setup manually instead of calling other script
|
# TODO: setup manually instead of calling other script
|
||||||
|
@ -275,7 +373,7 @@ class TestMigrations(TestCase):
|
||||||
self.run_transfer_domains()
|
self.run_transfer_domains()
|
||||||
|
|
||||||
# Analyze the tables
|
# Analyze the tables
|
||||||
expected_total_transition_domains = 8
|
expected_total_transition_domains = 9
|
||||||
expected_total_domains = 4
|
expected_total_domains = 4
|
||||||
expected_total_domain_informations = 4
|
expected_total_domain_informations = 4
|
||||||
expected_total_domain_invitations = 7
|
expected_total_domain_invitations = 7
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue