mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 19:09:22 +02:00
tentative changes to tests"
"
This commit is contained in:
parent
d4475f074e
commit
ffeed489c4
6 changed files with 39 additions and 6 deletions
|
@ -2,6 +2,7 @@ import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
|
||||||
def get_handlers():
|
def get_handlers():
|
||||||
|
@ -63,3 +64,16 @@ def less_console_noise_decorator(func):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def create_user():
|
||||||
|
username = "restricted_user"
|
||||||
|
first_name = "First"
|
||||||
|
last_name = "Last"
|
||||||
|
email = "restricted@example.com"
|
||||||
|
phone = "8003111234"
|
||||||
|
title = "title"
|
||||||
|
user = get_user_model().objects.create(
|
||||||
|
username=username, first_name=first_name, last_name=last_name, email=email, phone=phone, title=title
|
||||||
|
)
|
||||||
|
return user
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
|
||||||
from django.test import RequestFactory
|
from django.test import RequestFactory
|
||||||
|
|
||||||
from ..views import available, check_domain_available
|
from ..views import available, check_domain_available
|
||||||
from .common import less_console_noise
|
from .common import less_console_noise, create_user
|
||||||
from registrar.tests.common import MockEppLib
|
from registrar.tests.common import MockEppLib
|
||||||
from registrar.utility.errors import GenericError, GenericErrorCodes
|
from registrar.utility.errors import GenericError, GenericErrorCodes
|
||||||
from unittest.mock import call
|
from unittest.mock import call
|
||||||
|
@ -126,7 +126,7 @@ class AvailableAPITest(MockEppLib):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.user = get_user_model().objects.create(username="username")
|
self.user = create_user()
|
||||||
|
|
||||||
def test_available_get(self):
|
def test_available_get(self):
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
|
|
|
@ -845,6 +845,7 @@ def create_superuser():
|
||||||
last_name="last",
|
last_name="last",
|
||||||
is_staff=True,
|
is_staff=True,
|
||||||
password=p,
|
password=p,
|
||||||
|
phone="8003111234",
|
||||||
)
|
)
|
||||||
# Retrieve the group or create it if it doesn't exist
|
# Retrieve the group or create it if it doesn't exist
|
||||||
group, _ = UserGroup.objects.get_or_create(name="full_access_group")
|
group, _ = UserGroup.objects.get_or_create(name="full_access_group")
|
||||||
|
@ -862,7 +863,9 @@ def create_user():
|
||||||
first_name="first",
|
first_name="first",
|
||||||
last_name="last",
|
last_name="last",
|
||||||
is_staff=True,
|
is_staff=True,
|
||||||
|
title="title",
|
||||||
password=p,
|
password=p,
|
||||||
|
phone="8003111234",
|
||||||
)
|
)
|
||||||
# Retrieve the group or create it if it doesn't exist
|
# Retrieve the group or create it if it doesn't exist
|
||||||
group, _ = UserGroup.objects.get_or_create(name="cisa_analysts_group")
|
group, _ = UserGroup.objects.get_or_create(name="cisa_analysts_group")
|
||||||
|
@ -878,8 +881,15 @@ def create_test_user():
|
||||||
email = "info@example.com"
|
email = "info@example.com"
|
||||||
phone = "8003111234"
|
phone = "8003111234"
|
||||||
title = "test title"
|
title = "test title"
|
||||||
|
password = "password"
|
||||||
user = get_user_model().objects.create(
|
user = get_user_model().objects.create(
|
||||||
username=username, first_name=first_name, last_name=last_name, email=email, phone=phone, title=title
|
username=username,
|
||||||
|
first_name=first_name,
|
||||||
|
last_name=last_name,
|
||||||
|
email=email,
|
||||||
|
phone=phone,
|
||||||
|
title=title,
|
||||||
|
password=password,
|
||||||
)
|
)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
|
@ -350,6 +350,7 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
|
|
||||||
# Get the csv content
|
# Get the csv content
|
||||||
csv_content = self._run_domain_data_type_user_export(request)
|
csv_content = self._run_domain_data_type_user_export(request)
|
||||||
|
print(csv_content)
|
||||||
|
|
||||||
# We expect only domains associated with the user's portfolio
|
# We expect only domains associated with the user's portfolio
|
||||||
self.assertIn(self.domain_1.name, csv_content)
|
self.assertIn(self.domain_1.name, csv_content)
|
||||||
|
@ -389,6 +390,8 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
DomainDataTypeUser.export_data_to_csv(csv_file, request=request)
|
DomainDataTypeUser.export_data_to_csv(csv_file, request=request)
|
||||||
# Reset the CSV file's position to the beginning
|
# Reset the CSV file's position to the beginning
|
||||||
csv_file.seek(0)
|
csv_file.seek(0)
|
||||||
|
print(csv_file)
|
||||||
|
print(csv_file.seek(0))
|
||||||
# Read the content into a variable
|
# Read the content into a variable
|
||||||
csv_content = csv_file.read()
|
csv_content = csv_file.read()
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,13 @@ class HomeTests(TestWithUser):
|
||||||
phone = "8003111234"
|
phone = "8003111234"
|
||||||
status = User.RESTRICTED
|
status = User.RESTRICTED
|
||||||
restricted_user = get_user_model().objects.create(
|
restricted_user = get_user_model().objects.create(
|
||||||
username=username, first_name=first_name, last_name=last_name, email=email, phone=phone, status=status
|
username=username,
|
||||||
|
first_name=first_name,
|
||||||
|
last_name=last_name,
|
||||||
|
email=email,
|
||||||
|
phone=phone,
|
||||||
|
status=status,
|
||||||
|
title="title",
|
||||||
)
|
)
|
||||||
self.client.force_login(restricted_user)
|
self.client.force_login(restricted_user)
|
||||||
response = self.client.get("/request/", follow=True)
|
response = self.client.get("/request/", follow=True)
|
||||||
|
|
|
@ -723,7 +723,7 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
email_address = "mayor@igorville.gov"
|
email_address = "mayor@igorville.gov"
|
||||||
invitation, _ = DomainInvitation.objects.get_or_create(domain=self.domain, email=email_address)
|
invitation, _ = DomainInvitation.objects.get_or_create(domain=self.domain, email=email_address)
|
||||||
|
|
||||||
other_user = User()
|
other_user = create_user()
|
||||||
other_user.save()
|
other_user.save()
|
||||||
self.client.force_login(other_user)
|
self.client.force_login(other_user)
|
||||||
mock_client = MagicMock()
|
mock_client = MagicMock()
|
||||||
|
@ -759,7 +759,7 @@ class TestDomainManagers(TestDomainOverview):
|
||||||
new_user.on_each_login()
|
new_user.on_each_login()
|
||||||
|
|
||||||
# Now load the home page and make sure our domain appears there
|
# Now load the home page and make sure our domain appears there
|
||||||
home_page = self.app.get(reverse("home"))
|
home_page = self.app.get(reverse("user-profile"))
|
||||||
self.assertContains(home_page, self.domain.name)
|
self.assertContains(home_page, self.domain.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue