Allow unknown state in data migration

This commit is contained in:
Neil Martinsen-Burrell 2023-12-01 11:24:45 -06:00
parent 01b1e3e520
commit 45f8e26018
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
5 changed files with 14 additions and 14 deletions

View file

@ -176,6 +176,7 @@ class Command(BaseCommand):
"clienthold": TransitionDomain.StatusChoices.ON_HOLD,
"created": TransitionDomain.StatusChoices.READY,
"ok": TransitionDomain.StatusChoices.READY,
"unknown": TransitionDomain.StatusChoices.UNKNOWN,
}
mapped_status = status_maps.get(status_to_map)
return mapped_status

View file

@ -1338,19 +1338,6 @@ class Domain(TimeStampedModel, DomainHelper):
logger.info("Changing to DNS_NEEDED state")
logger.info("able to transition to DNS_NEEDED state")
@transition(
field="state",
source="*",
target=State.UNKNOWN,
)
def force_unknown(self):
"""Force a domain to go into our unknown state.
This can be useful on a limited basis when we need a domain
to be created in the registry for some reason.
"""
pass
def _disclose_fields(self, contact: PublicContact):
"""creates a disclose object that can be added to a contact Create using
.disclose= <this function> on the command before sending.

View file

@ -5,6 +5,7 @@ from .utility.time_stamped_model import TimeStampedModel
class StatusChoices(models.TextChoices):
READY = "ready", "Ready"
ON_HOLD = "on hold", "On Hold"
UNKNOWN = "unknown", "Unknown"
class TransitionDomain(TimeStampedModel):

View file

@ -2,4 +2,4 @@ Anomaly.gov|muahaha|
TestDomain.gov|ok|
FakeWebsite1.gov|serverHold|
FakeWebsite2.gov|Hold|
FakeWebsite3.gov|ok|
FakeWebsite3.gov|unknown|

View file

@ -193,6 +193,17 @@ class TestOrganizationMigration(TestCase):
self.assertEqual(transition, expected_transition_domain)
def test_transition_domain_status_unknown(self):
"""
Test that a domain in unknown status can be loaded
""" # noqa - E501 (harder to read)
# == First, parse all existing data == #
self.run_load_domains()
self.run_transfer_domains()
domain_object = Domain.objects.get(name="fakewebsite3.gov")
self.assertEqual(domain_object.state, Domain.State.UNKNOWN)
def test_load_organization_data_domain_information(self):
"""
This test verifies the functionality of the load_organization_data method.