mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
added test for case where no status
This commit is contained in:
parent
74fa04fd6c
commit
31d04c0269
2 changed files with 18 additions and 2 deletions
|
@ -267,11 +267,13 @@ class DomainApplicationAdminForm(forms.ModelForm):
|
||||||
instance = kwargs.get("instance")
|
instance = kwargs.get("instance")
|
||||||
if instance and instance.pk:
|
if instance and instance.pk:
|
||||||
current_state = instance.status
|
current_state = instance.status
|
||||||
|
|
||||||
|
# first option in status transitions is current state
|
||||||
|
available_transitions = [(current_state, current_state)]
|
||||||
|
|
||||||
transitions = get_available_FIELD_transitions(
|
transitions = get_available_FIELD_transitions(
|
||||||
instance, models.DomainApplication._meta.get_field("status")
|
instance, models.DomainApplication._meta.get_field("status")
|
||||||
)
|
)
|
||||||
# first option in status transitions is current state
|
|
||||||
available_transitions = [(current_state, current_state)]
|
|
||||||
|
|
||||||
for transition in transitions:
|
for transition in transitions:
|
||||||
available_transitions.append((transition.target, transition.target))
|
available_transitions.append((transition.target, transition.target))
|
||||||
|
|
|
@ -106,6 +106,20 @@ class TestDomainApplicationAdminForm(TestCase):
|
||||||
expected_choices = [("started", "started"), ("submitted", "submitted")]
|
expected_choices = [("started", "started"), ("submitted", "submitted")]
|
||||||
self.assertEqual(form.fields["status"].widget.choices, expected_choices)
|
self.assertEqual(form.fields["status"].widget.choices, expected_choices)
|
||||||
|
|
||||||
|
def test_form_choices_when_no_instance(self):
|
||||||
|
# Create a form instance without an instance
|
||||||
|
form = DomainApplicationAdminForm()
|
||||||
|
|
||||||
|
# Verify that the form choices show all choices when no instance is provided;
|
||||||
|
# this is necessary to show all choices when creating a new domain
|
||||||
|
# application in django admin;
|
||||||
|
# note that FSM ensures that no domain application exists with invalid status,
|
||||||
|
# so don't need to test for invalid status
|
||||||
|
self.assertEqual(
|
||||||
|
form.fields["status"].widget.choices,
|
||||||
|
DomainApplication._meta.get_field("status").choices,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDomainApplicationAdmin(TestCase):
|
class TestDomainApplicationAdmin(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue