mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 09:07:02 +02:00
added test for DomainAdmin to test_place_and_remove_hold; added mock data for mock domain
This commit is contained in:
parent
c52ccf8a9a
commit
744c6fa48a
2 changed files with 57 additions and 1 deletions
|
@ -2,12 +2,14 @@ from django.test import TestCase, RequestFactory, Client
|
|||
from django.contrib.admin.sites import AdminSite
|
||||
|
||||
from registrar.admin import (
|
||||
DomainAdmin,
|
||||
DomainApplicationAdmin,
|
||||
ListHeaderAdmin,
|
||||
MyUserAdmin,
|
||||
AuditedAdmin,
|
||||
)
|
||||
from registrar.models import (
|
||||
Domain,
|
||||
DomainApplication,
|
||||
DomainInformation,
|
||||
User,
|
||||
|
@ -18,6 +20,7 @@ from .common import (
|
|||
mock_user,
|
||||
create_superuser,
|
||||
create_user,
|
||||
create_ready_domain,
|
||||
multiple_unalphabetical_domain_objects,
|
||||
)
|
||||
|
||||
|
@ -32,6 +35,52 @@ import logging
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestDomainAdmin(TestCase):
|
||||
def setUp(self):
|
||||
self.site = AdminSite()
|
||||
self.factory = RequestFactory()
|
||||
self.admin = DomainAdmin(model=Domain, admin_site=self.site)
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.staffuser = create_user()
|
||||
|
||||
def test_place_and_remove_hold(self):
|
||||
domain = create_ready_domain()
|
||||
|
||||
# get admin page and assert Place Hold button
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domain/{}/change/".format(domain.pk),
|
||||
follow=True,
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain.name)
|
||||
self.assertContains(response, "Place hold")
|
||||
self.assertNotContains(response, "Remove hold")
|
||||
|
||||
# submit place_client_hold and assert Remove Hold button
|
||||
response = self.client.post(
|
||||
"/admin/registrar/domain/{}/change/".format(domain.pk),
|
||||
{"_place_client_hold": "Place hold", "name": domain.name},
|
||||
follow=True,
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain.name)
|
||||
self.assertContains(response, "Remove hold")
|
||||
self.assertNotContains(response, "Place hold")
|
||||
|
||||
# submit remove client hold and assert Place hold button
|
||||
response = self.client.post(
|
||||
"/admin/registrar/domain/{}/change/".format(domain.pk),
|
||||
{"_remove_client_hold": "Remove hold", "name": domain.name},
|
||||
follow=True,
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain.name)
|
||||
self.assertContains(response, "Place hold")
|
||||
self.assertNotContains(response, "Remove hold")
|
||||
|
||||
|
||||
class TestDomainApplicationAdmin(TestCase):
|
||||
def setUp(self):
|
||||
self.site = AdminSite()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue