added test case

This commit is contained in:
David Kennedy 2023-11-08 12:50:09 -05:00
parent d3a3565336
commit b84fdedc40
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 66 additions and 41 deletions

View file

@ -16,12 +16,23 @@
</div> </div>
<div class="grid-row grid-gap"> <div class="grid-row grid-gap">
<div class="tablet:grid-col-3"> <div class="tablet:grid-col-3">
{% if domain.domain_info %}
{% include 'domain_sidebar.html' %} {% include 'domain_sidebar.html' %}
{% endif %}
</div> </div>
<div class="tablet:grid-col-9"> <div class="tablet:grid-col-9">
<main id="main-content" class="grid-container"> <main id="main-content" class="grid-container">
{% if not domain.domain_info %}
<div class="usa-alert usa-alert--error margin-bottom-2">
<div class="usa-alert__body">
<h4 class="usa-alert__heading larger-font-sizing">Error!</h4>
<p class="usa-alert__text ">
You are attempting to manage a domain, {{ domain.name }}, which does not have a Domain Information object. Please correct this in the admin.
</p>
</div>
</div>
{% else %}
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %} {% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
<div class="usa-alert usa-alert--warning margin-bottom-2"> <div class="usa-alert usa-alert--warning margin-bottom-2">
<div class="usa-alert__body"> <div class="usa-alert__body">
@ -58,7 +69,7 @@
<h1 class="break-word">{{ domain.name }}</h1> <h1 class="break-word">{{ domain.name }}</h1>
{% endblock %} {# domain_content #} {% endblock %} {# domain_content #}
{% endif %}
</main> </main>
</div> </div>
</div> </div>

View file

@ -453,7 +453,7 @@ def create_user():
p = "userpass" p = "userpass"
user = User.objects.create_user( user = User.objects.create_user(
username="staffuser", username="staffuser",
email="user@example.com", email="staff@example.com",
is_staff=True, is_staff=True,
password=p, password=p,
) )

View file

@ -5,7 +5,7 @@ from django.conf import settings
from django.test import Client, TestCase from django.test import Client, TestCase
from django.urls import reverse from django.urls import reverse
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from .common import MockEppLib, completed_application # type: ignore from .common import MockEppLib, completed_application, create_user # type: ignore
from django_webtest import WebTest # type: ignore from django_webtest import WebTest # type: ignore
import boto3_mocking # type: ignore import boto3_mocking # type: ignore
@ -1282,13 +1282,27 @@ class TestDomainOverview(TestWithDomainPermissions, WebTest):
self.assertContains(detail_page, "2.3.4.5)") self.assertContains(detail_page, "2.3.4.5)")
def test_domain_with_no_information_or_application(self): def test_domain_with_no_information_or_application(self):
"""Test that domain management page returns 200 when no """Test that domain management page returns 200 and displays error
domain information or domain application exist""" when no domain information or domain application exist"""
detail_page = self.app.get( # have to use staff user for this test
staff_user = create_user()
# staff_user.save()
self.client.force_login(staff_user)
# need to set the analyst_action and analyst_action_location
# in the session to emulate user clicking Manage Domain
# in the admin interface
session = self.client.session
session['analyst_action'] = 'foo'
session['analyst_action_location'] = self.domain_no_information.id
session.save()
detail_page = self.client.get(
reverse("domain", kwargs={"pk": self.domain_no_information.id}) reverse("domain", kwargs={"pk": self.domain_no_information.id})
) )
self.assertContains(detail_page, "noinformation.gov") self.assertContains(detail_page, "noinformation.gov")
self.assertContains(detail_page, "Error")
class TestDomainManagers(TestDomainOverview): class TestDomainManagers(TestDomainOverview):