mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-28 09:50:46 +02:00
Add unit tests
This commit is contained in:
parent
b23f361a08
commit
816cbe23dd
2 changed files with 57 additions and 7 deletions
|
@ -28,7 +28,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th data-sortable scope="col" role="columnheader">Email</th>
|
||||
<th data-sortable scope="col" role="columnheader">Role</th>
|
||||
<th class="grid-col-2" data-sortable scope="col" role="columnheader">Role</th>
|
||||
<th class="grid-col-1" scope="col" role="columnheader"><span class="sr-only">Action</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -125,8 +125,8 @@
|
|||
<tr>
|
||||
<th data-sortable scope="col" role="columnheader">Email</th>
|
||||
<th data-sortable scope="col" role="columnheader">Date created</th>
|
||||
<th data-sortable scope="col" role="columnheader">Status</th>
|
||||
<th scope="col" role="columnheader"><span class="sr-only">Action</span></th>
|
||||
<th class="grid-col-2" data-sortable scope="col" role="columnheader">Status</th>
|
||||
<th class="grid-col-1" scope="col" role="columnheader"><span class="sr-only">Action</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -137,7 +137,7 @@
|
|||
</th>
|
||||
<td data-sort-value="{{ invitation.created_at|date:"U" }}" data-label="Date created">{{ invitation.created_at|date }} </td>
|
||||
<td data-label="Status">{{ invitation.status|title }}</td>
|
||||
<td><form method="POST" action="{% url "invitation-delete" pk=invitation.id %}">
|
||||
<td class="padding-left-2px"><form method="POST" action="{% url "invitation-delete" pk=invitation.id %}">
|
||||
{% csrf_token %}<input type="submit" class="usa-button--unstyled text-no-underline" value="Cancel">
|
||||
</form>
|
||||
</td>
|
||||
|
|
|
@ -2543,6 +2543,7 @@ class TestDomainManagers(TestDomainOverview):
|
|||
super().tearDown()
|
||||
self.user.is_staff = False
|
||||
self.user.save()
|
||||
User.objects.all().delete()
|
||||
|
||||
def test_domain_managers(self):
|
||||
response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id}))
|
||||
|
@ -2609,13 +2610,62 @@ class TestDomainManagers(TestDomainOverview):
|
|||
self.assertTrue(role_2_exists)
|
||||
|
||||
# Check that the view no longer displays the deleted user
|
||||
# TODO - why is this not working?
|
||||
# why is this not working? Its not in the response when printed?
|
||||
# self.assertNotContains(response, "cheese@igorville.com")
|
||||
|
||||
@skip("TODO")
|
||||
def test_domain_delete_self_redirects_home(self):
|
||||
"""Tests if deleting yourself redirects to home"""
|
||||
raise
|
||||
# Add additional users
|
||||
dummy_user_1 = User.objects.create(
|
||||
username="macncheese",
|
||||
email="cheese@igorville.com",
|
||||
)
|
||||
dummy_user_2 = User.objects.create(
|
||||
username="pastapizza",
|
||||
email="pasta@igorville.com",
|
||||
)
|
||||
|
||||
role_1 = UserDomainRole.objects.create(user=dummy_user_1, domain=self.domain, role=UserDomainRole.Roles.MANAGER)
|
||||
role_2 = UserDomainRole.objects.create(user=dummy_user_2, domain=self.domain, role=UserDomainRole.Roles.MANAGER)
|
||||
|
||||
response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id}))
|
||||
|
||||
# Make sure we're on the right page
|
||||
self.assertContains(response, "Domain managers")
|
||||
|
||||
# Make sure the desired user exists
|
||||
self.assertContains(response, "info@example.com")
|
||||
|
||||
# Make sure more than one UserDomainRole exists on this object
|
||||
self.assertContains(response, "cheese@igorville.com")
|
||||
|
||||
# Delete the current user
|
||||
response = self.client.post(
|
||||
reverse("domain-user-delete", kwargs={"pk": self.domain.id, "user_pk": self.user.id}), follow=True
|
||||
)
|
||||
|
||||
# Check if we've been redirected to the home page
|
||||
self.assertContains(response, "Manage your domains")
|
||||
|
||||
# Grab the displayed messages
|
||||
messages = list(response.context["messages"])
|
||||
self.assertEqual(len(messages), 1)
|
||||
|
||||
# Ensure the error we recieve is in line with what we expect
|
||||
message = messages[0]
|
||||
self.assertEqual(message.message, "You are no longer managing the domain igorville.gov")
|
||||
self.assertEqual(message.tags, "success")
|
||||
|
||||
# Ensure that the current user was deleted
|
||||
current_user_exists = UserDomainRole.objects.filter(user=self.user.id).exists()
|
||||
self.assertFalse(current_user_exists)
|
||||
|
||||
# Ensure that the other userdomainroles are not deleted
|
||||
role_1_exists = UserDomainRole.objects.filter(id=role_1.id).exists()
|
||||
self.assertTrue(role_1_exists)
|
||||
|
||||
role_2_exists = UserDomainRole.objects.filter(id=role_2.id).exists()
|
||||
self.assertTrue(role_2_exists)
|
||||
|
||||
@boto3_mocking.patching
|
||||
def test_domain_user_add_form(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue