mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-20 03:19:24 +02:00
Test data and test changes
This commit is contained in:
parent
4e22e26065
commit
44c7631eaa
14 changed files with 131 additions and 29 deletions
|
@ -72,7 +72,9 @@ class Command(BaseCommand):
|
|||
"--directory", default="migrationdata", help="Desired directory"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--infer_filenames", default=False, help="Determines if we should infer filenames or not. Recommended to be enabled only in a development or testing setting."
|
||||
"--infer_filenames",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
help="Determines if we should infer filenames or not. Recommended to be enabled only in a development or testing setting."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--agency_adhoc_filename",
|
||||
|
@ -86,10 +88,9 @@ class Command(BaseCommand):
|
|||
)
|
||||
parser.add_argument(
|
||||
"--domain_escrow_filename",
|
||||
default=EnumFilenames.DOMAIN_ADDITIONAL.value[1],
|
||||
default=EnumFilenames.DOMAIN_ESCROW.value[1],
|
||||
help="Defines the filename for creation/expiration domain data",
|
||||
)
|
||||
#domain_escrow_filename
|
||||
parser.add_argument(
|
||||
"--domain_adhoc_filename",
|
||||
default=EnumFilenames.DOMAIN_ADHOC.value[1],
|
||||
|
|
|
@ -151,7 +151,7 @@ class LoadExtraTransitionDomain:
|
|||
updated_transition_domains = []
|
||||
failed_transition_domains = []
|
||||
for transition_domain in all_transition_domains:
|
||||
domain_name = transition_domain.domain_name.upper()
|
||||
domain_name = transition_domain.domain_name
|
||||
updated_transition_domain = transition_domain
|
||||
try:
|
||||
# STEP 1: Parse organization data
|
||||
|
@ -188,6 +188,7 @@ class LoadExtraTransitionDomain:
|
|||
|
||||
# If we run into an exception on this domain,
|
||||
# Just skip over it and log that it happened.
|
||||
# Q: Should we just throw an exception?
|
||||
except Exception as err:
|
||||
logger.debug(err)
|
||||
logger.error(
|
||||
|
@ -511,6 +512,8 @@ class LoadExtraTransitionDomain:
|
|||
def get_domain_data(self, desired_id) -> DomainAdditionalData:
|
||||
"""Grabs a corresponding row within the DOMAIN_ADDITIONAL file,
|
||||
based off a desired_id"""
|
||||
l = self.get_object_by_id(EnumFilenames.DOMAIN_ADDITIONAL, desired_id.lower())
|
||||
print(f"is it happening here? {l} for id {desired_id}")
|
||||
return self.get_object_by_id(EnumFilenames.DOMAIN_ADDITIONAL, desired_id)
|
||||
|
||||
def get_organization_adhoc(self, desired_id) -> OrganizationAdhoc:
|
||||
|
@ -889,11 +892,6 @@ class ExtraTransitionDomain:
|
|||
def _read_csv_file(self, file, seperator, dataclass_type, id_field):
|
||||
with open(file, "r", encoding="utf-8-sig") as requested_file:
|
||||
reader = csv.DictReader(requested_file, delimiter=seperator)
|
||||
"""
|
||||
for row in reader:
|
||||
print({key: type(key) for key in row.keys()}) # print out the keys and their types
|
||||
test = {row[id_field]: dataclass_type(**row)}
|
||||
"""
|
||||
dict_data = {}
|
||||
for row in reader:
|
||||
if None in row:
|
||||
|
@ -903,6 +901,11 @@ class ExtraTransitionDomain:
|
|||
print(f"key: {key} value: {value}")
|
||||
continue
|
||||
row_id = row[id_field]
|
||||
|
||||
# To maintain pairity with the load_transition_domain
|
||||
# script, we store this data in lowercase.
|
||||
if id_field == "domainname" and row_id is not None:
|
||||
row_id = row_id.lower()
|
||||
dict_data[row_id] = dataclass_type(**row)
|
||||
# dict_data = {row[id_field]: dataclass_type(**row) for row in reader}
|
||||
return dict_data
|
||||
|
|
|
@ -5,13 +5,30 @@ from registrar.management.commands.utility.epp_data_containers import EnumFilena
|
|||
|
||||
@dataclass
|
||||
class TransitionDomainArguments:
|
||||
"""Stores arguments for load_transition_domain"""
|
||||
"""Stores arguments for load_transition_domain, structurally a mix
|
||||
of a dataclass and a regular class, meaning we get a hardcoded
|
||||
representation of the values we want, while maintaining flexiblity
|
||||
and reducing boilerplate.
|
||||
|
||||
All pre-defined fields are optional but will remain on the model definition.
|
||||
In this event, they are provided a default value if none is given.
|
||||
"""
|
||||
|
||||
# Maintains an internal kwargs list and sets values
|
||||
# that match the class definition.
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
for k, v in kwargs.items():
|
||||
if hasattr(self, k):
|
||||
setattr(self, k, v)
|
||||
|
||||
# These all use field() to minimize typing and/or lambda.
|
||||
# Since this file is bound to expand, we can save time
|
||||
# by reducing the line count from 2-3 to just 1 line
|
||||
# each time we want to add a new filename or option.
|
||||
|
||||
# This approach is also used in EppLib internally for similar reasons.
|
||||
|
||||
# Settings #
|
||||
directory: Optional[str] = field(default="migrationdata", repr=True)
|
||||
sep: Optional[str] = field(default="|", repr=True)
|
||||
|
|
|
@ -79,6 +79,20 @@ class TransitionDomain(TimeStampedModel):
|
|||
)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
return f"""
|
||||
username="{self.username}",
|
||||
domain_name="{self.domain_name}",
|
||||
status="{self.status}",
|
||||
email_sent={self.email_sent},
|
||||
organization_type="{self.organization_type}",
|
||||
organization_name="{self.organization_name}",
|
||||
federal_type="{self.federal_type}",
|
||||
federal_agency="{self.federal_agency}",
|
||||
epp_creation_date={self.epp_creation_date},
|
||||
epp_expiration_date={self.epp_expiration_date}
|
||||
"""
|
||||
"""
|
||||
return (
|
||||
f"\n-----TRANSITION DOMAIN------\n"
|
||||
f"domainName: {self.domain_name}, \n"
|
||||
|
@ -91,4 +105,4 @@ class TransitionDomain(TimeStampedModel):
|
|||
f"federal_agency: {self.federal_agency}, \n"
|
||||
f"epp_creation_date: {self.epp_creation_date}, \n"
|
||||
f"epp_expiration_date: {self.epp_expiration_date}, \n"
|
||||
)
|
||||
)"""
|
||||
|
|
|
@ -3,3 +3,4 @@ agencyid|agencyname|active|isfederal
|
|||
2|Minyx|Y|N
|
||||
3|Demivee|N|Y
|
||||
4|InnoZ|Y|Y
|
||||
5|igorville|Y|N
|
|
@ -3,3 +3,4 @@ authorityid|firstname|middlename|lastname|email|phonenumber|agencyid|addlinfo
|
|||
2|Fayre||Filippozzi|ffilippozzi1@hugedomains.com|(357) 487-4280|2|Steampan - Foil
|
||||
3|Gabey||Lightbody|glightbody2@fc2.com|(332) 816-5691|3|Soup - Campbells, Minestrone
|
||||
4|Seline||Tower|stower3@answers.com|(151) 539-6028|4|Kiwi Gold Zespri
|
||||
5|Joe||Smoe|joe@smoe.gov|(111) 111-1111|5|Kiwi Gold Zespri
|
|
@ -5,3 +5,6 @@ USER3|12356_CONTACT|123-123-1234||918-000-0000||stephania.winters4@test.com|GSA|
|
|||
USER4|12357_CONTACT|123-123-1234||918-000-0000||alexandra.bobbitt5@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T15:23:10Z|SOMECOMPANY|ctldbatch|2021-08-02T22:13:09Z|
|
||||
USER5|12362_CONTACT|123-123-1234||918-000-0000||jospeh.mcdowell3@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T17:58:09Z|SOMECOMPANY|ctldbatch|2021-06-30T18:33:09Z|
|
||||
USER6|12363_CONTACT|123-123-1234||918-000-0000||reginald.ratcliff4@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T17:58:09Z|SOMECOMPANY|ctldbatch|2021-06-30T18:18:09Z|
|
||||
USER7|12364_CONTACT|123-123-1234||918-000-0000||reginald.ratcliff4@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T17:58:09Z|SOMECOMPANY|ctldbatch|2021-06-30T18:18:09Z|
|
||||
USER8|12365_CONTACT|123-123-1234||918-000-0000||reginald.ratcliff4@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T17:58:09Z|SOMECOMPANY|ctldbatch|2021-06-30T18:18:09Z|
|
||||
USER9|12366_CONTACT|123-123-1234||918-000-0000||reginald.ratcliff4@test.com|GSA|SOMECOMPANY|ctldbatch|2021-06-30T17:58:09Z|SOMECOMPANY|ctldbatch|2021-06-30T18:18:09Z|
|
|
@ -1,5 +1,6 @@
|
|||
domainname|domaintypeid|authorityid|orgid|securitycontactemail|dnsseckeymonitor|domainpurpose
|
||||
Anomaly.gov|1|1|1|ggennrich0@utexas.edu|N|Praesent id massa id nisl venenatis lacinia.
|
||||
TestDomain.gov|2|2|2|lrome1@uol.com.br|Y|In tempor, turpis nec euismod scelerisque, quam turpis adipiscing lorem, vitae mattis nibh ligula nec sem.
|
||||
FakeWebsite1.GOV|3|3|3|ybrommage2@vistaprint.com|Y|In hac habitasse platea dictumst.
|
||||
FakeWebsite2.GOV|4|4|4|plarderot3@t.co|Y|Morbi quis tortor id nulla ultrices aliquet. Maecenas leo odio, condimentum id, luctus nec, molestie sed, justo. Pellentesque viverra pede ac diam.
|
||||
TESTDOMAIN.GOV|2|2|2|lrome1@uol.com.br|Y|In tempor, turpis nec euismod scelerisque, quam turpis adipiscing lorem, vitae mattis nibh ligula nec sem.
|
||||
FakeWebsite1.gov|3|3|3|ybrommage2@vistaprint.com|Y|In hac habitasse platea dictumst.
|
||||
FakeWebsite2.gov|4|4|4|plarderot3@t.co|Y|Morbi quis tortor id nulla ultrices aliquet. Maecenas leo odio, condimentum id, luctus nec, molestie sed, justo. Pellentesque viverra pede ac diam.
|
||||
FakeWebsite3.gov|13|5|5|ybrommage2@vistaprint.com|Y|In hac habitasse platea dictumst.
|
|
@ -1,8 +1,11 @@
|
|||
Anomaly.gov|ANOMALY|tech
|
||||
TestDomain.gov|TESTUSER|admin
|
||||
FakeWebsite1|USER1|admin
|
||||
FakeWebsite1|USER2|tech
|
||||
FakeWebsite1|USER3|billing
|
||||
FakeWebsite2.GOV|USER4|admin
|
||||
FakeWebsite2.GOV|USER5|billing
|
||||
FakeWebsite2.GOV|USER6|tech
|
||||
FakeWebsite1.gov|USER1|admin
|
||||
FakeWebsite1.gov|USER2|tech
|
||||
FakeWebsite1.gov|USER3|billing
|
||||
FakeWebsite2.gov|USER4|admin
|
||||
FakeWebsite2.gov|USER5|billing
|
||||
FakeWebsite2.gov|USER6|tech
|
||||
FakeWebsite3.gov|USER7|admin
|
||||
FakeWebsite3.gov|USER8|billing
|
||||
FakeWebsite3.gov|USER9|tech
|
|
@ -1,4 +1,5 @@
|
|||
Anomaly.gov|muahaha|
|
||||
TestDomain.gov|ok|
|
||||
FakeWebsite1.GOV|serverHold|
|
||||
FakeWebsite2.GOV|Hold|
|
||||
FakeWebsite1.gov|serverHold|
|
||||
FakeWebsite2.gov|Hold|
|
||||
FakeWebsite3.gov|ok|
|
|
@ -0,0 +1,5 @@
|
|||
Anomaly.gov|SOME_STRING||data|data|data|data|2008-03-09T16:12:47Z|DATA2|ctldbatch|2022-06-06T01:33:10Z|2023-03-09T16:12:47Z|2023-02-09T16:12:47Z
|
||||
TestDomain.gov|SOME_STRING|data|data|data|data|data|2014-03-15T15:45:05Z|DATA2|ctldbatch|2022-02-13T17:33:07Z|2023-03-15T15:45:05Z|2023-02-15T15:45:05Z
|
||||
FakeWebsite1.gov|SOME_STRING||data|data|data|data|2020-06-14T16:30:06Z|DATA2|ctldbatch|2022-05-16T14:58:10Z|2023-06-14T16:30:06Z|2023-05-14T16:30:06Z
|
||||
FakeWebsite2.gov|SOME_STRING||data|data|data|data|2004-05-07T04:00:00Z|DATA2|ctldbatch|2022-08-18T15:23:09Z|2023-09-30T18:37:39Z|2023-08-30T18:37:39Z
|
||||
FakeWebsite3.gov|SOME_STRING||data|data|data|data|2004-05-07T04:00:00Z|DATA2|ctldbatch|2022-08-18T15:23:09Z|2023-09-30T18:37:39Z|2023-08-30T18:37:39Z
|
|
@ -1,5 +1,6 @@
|
|||
orgid|orgname|orgstreet|orgcity|orgstate|orgzip|orgcountrycode
|
||||
1|Flashdog|298 Monument Hill|Lakeland|Florida|33805|US
|
||||
2|Gigaclub|782 Mosinee Lane|Alexandria|Louisiana|71307|US
|
||||
3|Midel|376 Donald Pass|Waco|Texas|76705|US
|
||||
3|Midel|376 Joe Pass|Waco|Texas|76705|US
|
||||
4|Fanoodle|93001 Arizona Drive|Columbus|Ohio|43268|US
|
||||
5|Sushi|9999 Sushi Way|Columbus|Ohio|43268|US
|
|
@ -216,7 +216,58 @@ class TestMigrations(TestCase):
|
|||
)
|
||||
|
||||
def test_load_full_transition_domain(self):
|
||||
pass
|
||||
# Load command
|
||||
self.run_load_domains()
|
||||
|
||||
# We should get a consistent number
|
||||
# of records
|
||||
expected_total_transition_domains = 8
|
||||
expected_total_domains = 0
|
||||
expected_total_domain_informations = 0
|
||||
expected_total_domain_invitations = 0
|
||||
|
||||
expected_missing_domains = 8
|
||||
expected_duplicate_domains = 0
|
||||
expected_missing_domain_informations = 8
|
||||
expected_missing_domain_invitations = 8
|
||||
self.compare_tables(
|
||||
expected_total_transition_domains,
|
||||
expected_total_domains,
|
||||
expected_total_domain_informations,
|
||||
expected_total_domain_invitations,
|
||||
expected_missing_domains,
|
||||
expected_duplicate_domains,
|
||||
expected_missing_domain_informations,
|
||||
expected_missing_domain_invitations,
|
||||
)
|
||||
|
||||
expected_transition_domains = [
|
||||
TransitionDomain(
|
||||
username="",
|
||||
domain_name="anomaly.gov",
|
||||
status="ready",
|
||||
email_sent=False,
|
||||
organization_type="None",
|
||||
organization_name="Flashdog",
|
||||
federal_type="None",
|
||||
federal_agency="None",
|
||||
epp_creation_date=None,
|
||||
epp_expiration_date=None
|
||||
),
|
||||
TransitionDomain(
|
||||
username="",
|
||||
domain_name="anomaly.gov",
|
||||
status="ready",
|
||||
email_sent=False,
|
||||
organization_type="None",
|
||||
organization_name="Flashdog",
|
||||
federal_type="None",
|
||||
federal_agency="None",
|
||||
epp_creation_date=None,
|
||||
epp_expiration_date=None
|
||||
),
|
||||
]
|
||||
# Afterwards, their values should be what we expect
|
||||
|
||||
def test_transfer_transition_domains_to_domains(self):
|
||||
# TODO: setup manually instead of calling other script
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue