mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-12 15:34:50 +02:00
Add unit tests and cleanup
This commit is contained in:
parent
eb3850458b
commit
ef0e1c081b
2 changed files with 51 additions and 8 deletions
|
@ -58,12 +58,6 @@
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
{% if DomainRequest.creator and DomainRequest.creator != request.user %}
|
|
||||||
<p class="margin-top-1 margin-bottom-1">
|
|
||||||
<b class="review__step__name">Created by:</b> {{DomainRequest.creator.email|default:DomainRequest.creator.get_formatted_name }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% with statuses=DomainRequest.DomainRequestStatus last_submitted=DomainRequest.last_submitted_date|date:"F j, Y" first_submitted=DomainRequest.first_submitted_date|date:"F j, Y" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %}
|
{% with statuses=DomainRequest.DomainRequestStatus last_submitted=DomainRequest.last_submitted_date|date:"F j, Y" first_submitted=DomainRequest.first_submitted_date|date:"F j, Y" last_status_update=DomainRequest.last_status_update|date:"F j, Y" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
These are intentionally seperated this way.
|
These are intentionally seperated this way.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from unittest import skip
|
from unittest import skip
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock, patch
|
||||||
|
from datetime import datetime
|
||||||
|
from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from api.tests.common import less_console_noise_decorator
|
from api.tests.common import less_console_noise_decorator
|
||||||
|
@ -55,6 +56,54 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:"))
|
||||||
self.assertContains(intro_page, "You’re about to start your .gov domain request")
|
self.assertContains(intro_page, "You’re about to start your .gov domain request")
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
|
def test_template_status_display(self):
|
||||||
|
"""Tests the display of status-related information in the template."""
|
||||||
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.SUBMITTED, user=self.user)
|
||||||
|
domain_request.last_submitted_date = datetime.now()
|
||||||
|
domain_request.save()
|
||||||
|
response = self.app.get(f"/domain-request/{domain_request.id}")
|
||||||
|
self.assertContains(response, "Submitted on:")
|
||||||
|
self.assertContains(response, domain_request.last_submitted_date.strftime("%B %-d, %Y"))
|
||||||
|
|
||||||
|
@patch.object(DomainRequest, "get_first_status_set_date")
|
||||||
|
def test_get_first_status_started_date(self, mock_get_first_status_set_date):
|
||||||
|
"""Tests retrieval of the first date the status was set to 'started'."""
|
||||||
|
|
||||||
|
# Set the mock to return a fixed date
|
||||||
|
fixed_date = timezone.datetime(2023, 1, 1).date()
|
||||||
|
mock_get_first_status_set_date.return_value = fixed_date
|
||||||
|
|
||||||
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
|
||||||
|
domain_request.last_status_update = None
|
||||||
|
domain_request.save()
|
||||||
|
|
||||||
|
response = self.app.get(f"/domain-request/{domain_request.id}")
|
||||||
|
# Ensure that the date is still set to None
|
||||||
|
self.assertIsNone(domain_request.last_status_update)
|
||||||
|
print(response)
|
||||||
|
# We should still grab a date for this field in this event - but it should come from the audit log instead
|
||||||
|
self.assertContains(response, "Started on:")
|
||||||
|
self.assertContains(response, fixed_date.strftime("%B %-d, %Y"))
|
||||||
|
|
||||||
|
# If a status date is set, we display that instead
|
||||||
|
domain_request.last_status_update = datetime.now()
|
||||||
|
domain_request.save()
|
||||||
|
|
||||||
|
response = self.app.get(f"/domain-request/{domain_request.id}")
|
||||||
|
|
||||||
|
# We should still grab a date for this field in this event - but it should come from the audit log instead
|
||||||
|
self.assertContains(response, "Started on:")
|
||||||
|
self.assertContains(response, domain_request.last_status_update.strftime("%B %-d, %Y"))
|
||||||
|
|
||||||
|
def test_template_new_domain_request_display(self):
|
||||||
|
"""Tests the display of the new domain request header."""
|
||||||
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED, user=self.user)
|
||||||
|
domain_request.requested_domain = None
|
||||||
|
domain_request.save()
|
||||||
|
response = self.app.get(f"/domain-request/{domain_request.id}")
|
||||||
|
self.assertContains(response, "New domain request")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_intro_is_skipped_when_edit_access(self):
|
def test_domain_request_form_intro_is_skipped_when_edit_access(self):
|
||||||
"""Tests that user is NOT presented with intro acknowledgement page when accessed through 'edit'"""
|
"""Tests that user is NOT presented with intro acknowledgement page when accessed through 'edit'"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue