mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 10:59:21 +02:00
changes for linter
This commit is contained in:
parent
9da326be16
commit
248dd4adfc
6 changed files with 33 additions and 16 deletions
|
@ -260,4 +260,3 @@ class TestConnectionPool(TestCase):
|
||||||
expected = "InfoDomain failed to execute due to a connection error."
|
expected = "InfoDomain failed to execute due to a connection error."
|
||||||
result = registry.send(commands.InfoDomain(name="test.gov"), cleaned=True)
|
result = registry.send(commands.InfoDomain(name="test.gov"), cleaned=True)
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
|
|
@ -263,9 +263,7 @@ class TestExtendExpirationDates(MockEppLib):
|
||||||
epp_expiration_date=date(2023, 11, 15),
|
epp_expiration_date=date(2023, 11, 15),
|
||||||
)
|
)
|
||||||
# Create a domain with an invalid expiration date
|
# Create a domain with an invalid expiration date
|
||||||
Domain.objects.get_or_create(
|
Domain.objects.get_or_create(name="fake.gov", state=Domain.State.READY, expiration_date=date(2022, 5, 25))
|
||||||
name="fake.gov", state=Domain.State.READY, expiration_date=date(2022, 5, 25)
|
|
||||||
)
|
|
||||||
TransitionDomain.objects.get_or_create(
|
TransitionDomain.objects.get_or_create(
|
||||||
username="themoonisactuallycheese@mail.com",
|
username="themoonisactuallycheese@mail.com",
|
||||||
domain_name="fake.gov",
|
domain_name="fake.gov",
|
||||||
|
|
|
@ -743,9 +743,11 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
self.domain_contact.get_security_email()
|
self.domain_contact.get_security_email()
|
||||||
# invalidate the cache so the next time get_security_email is called, it has to attempt to populate cache
|
# invalidate the cache so the next time get_security_email is called, it has to attempt to populate cache
|
||||||
self.domain_contact._invalidate_cache()
|
self.domain_contact._invalidate_cache()
|
||||||
|
|
||||||
# mock that registry throws an error on the EPP send
|
# mock that registry throws an error on the EPP send
|
||||||
def side_effect(_request, cleaned):
|
def side_effect(_request, cleaned):
|
||||||
raise RegistryError(code=ErrorCode.COMMAND_FAILED)
|
raise RegistryError(code=ErrorCode.COMMAND_FAILED)
|
||||||
|
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
mocked_send.side_effect = side_effect
|
mocked_send.side_effect = side_effect
|
||||||
|
@ -1236,6 +1238,7 @@ class TestRegistrantNameservers(MockEppLib):
|
||||||
nameserver12 = "ns1.cats-are-superior12.com"
|
nameserver12 = "ns1.cats-are-superior12.com"
|
||||||
nameserver13 = "ns1.cats-are-superior13.com"
|
nameserver13 = "ns1.cats-are-superior13.com"
|
||||||
nameserver14 = "ns1.cats-are-superior14.com"
|
nameserver14 = "ns1.cats-are-superior14.com"
|
||||||
|
|
||||||
def _get_14_nameservers():
|
def _get_14_nameservers():
|
||||||
self.domain.nameservers = [
|
self.domain.nameservers = [
|
||||||
(nameserver1,),
|
(nameserver1,),
|
||||||
|
@ -1253,6 +1256,7 @@ class TestRegistrantNameservers(MockEppLib):
|
||||||
(nameserver13,),
|
(nameserver13,),
|
||||||
(nameserver14,),
|
(nameserver14,),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.assertRaises(NameserverError, _get_14_nameservers)
|
self.assertRaises(NameserverError, _get_14_nameservers)
|
||||||
self.assertEqual(self.mockedSendFunction.call_count, 0)
|
self.assertEqual(self.mockedSendFunction.call_count, 0)
|
||||||
|
|
||||||
|
@ -1553,9 +1557,11 @@ class TestRegistrantNameservers(MockEppLib):
|
||||||
# fetch_cache
|
# fetch_cache
|
||||||
host, _ = Host.objects.get_or_create(domain=domain, name="ns1.fake.gov")
|
host, _ = Host.objects.get_or_create(domain=domain, name="ns1.fake.gov")
|
||||||
host_ip, _ = HostIP.objects.get_or_create(host=host, address="1.1.1.1")
|
host_ip, _ = HostIP.objects.get_or_create(host=host, address="1.1.1.1")
|
||||||
|
|
||||||
# mock that registry throws an error on the InfoHost send
|
# mock that registry throws an error on the InfoHost send
|
||||||
def side_effect(_request, cleaned):
|
def side_effect(_request, cleaned):
|
||||||
raise RegistryError(code=ErrorCode.COMMAND_FAILED)
|
raise RegistryError(code=ErrorCode.COMMAND_FAILED)
|
||||||
|
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
mocked_send.side_effect = side_effect
|
mocked_send.side_effect = side_effect
|
||||||
|
@ -1729,6 +1735,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return MagicMock(res_data=[self.mockDataInfoHosts])
|
return MagicMock(res_data=[self.mockDataInfoHosts])
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
|
@ -1806,6 +1813,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return MagicMock(res_data=[self.mockDataInfoHosts])
|
return MagicMock(res_data=[self.mockDataInfoHosts])
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
|
@ -1879,6 +1887,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return MagicMock(res_data=[self.mockDataInfoHosts])
|
return MagicMock(res_data=[self.mockDataInfoHosts])
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
|
@ -1947,6 +1956,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return MagicMock(res_data=[self.mockDataInfoHosts])
|
return MagicMock(res_data=[self.mockDataInfoHosts])
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
|
@ -2271,6 +2281,7 @@ class TestAnalystClientHold(MockEppLib):
|
||||||
|
|
||||||
def side_effect(_request, cleaned):
|
def side_effect(_request, cleaned):
|
||||||
raise RegistryError(code=ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION)
|
raise RegistryError(code=ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION)
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
patcher = patch("registrar.models.domain.registry.send")
|
patcher = patch("registrar.models.domain.registry.send")
|
||||||
mocked_send = patcher.start()
|
mocked_send = patcher.start()
|
||||||
|
|
|
@ -25,6 +25,7 @@ from datetime import date, datetime, timedelta
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from .common import less_console_noise
|
from .common import less_console_noise
|
||||||
|
|
||||||
|
|
||||||
class CsvReportsTest(TestCase):
|
class CsvReportsTest(TestCase):
|
||||||
"""Tests to determine if we are uploading our reports correctly"""
|
"""Tests to determine if we are uploading our reports correctly"""
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ class CsvReportsTest(TestCase):
|
||||||
|
|
||||||
def side_effect(Bucket, Key):
|
def side_effect(Bucket, Key):
|
||||||
raise ClientError({"Error": {"Code": "NoSuchKey", "Message": "No such key"}}, "get_object")
|
raise ClientError({"Error": {"Code": "NoSuchKey", "Message": "No such key"}}, "get_object")
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
mock_client = MagicMock()
|
mock_client = MagicMock()
|
||||||
mock_client.get_object.side_effect = side_effect
|
mock_client.get_object.side_effect = side_effect
|
||||||
|
@ -145,6 +147,7 @@ class CsvReportsTest(TestCase):
|
||||||
|
|
||||||
def side_effect(Bucket, Key):
|
def side_effect(Bucket, Key):
|
||||||
raise ClientError({"Error": {"Code": "NoSuchKey", "Message": "No such key"}}, "get_object")
|
raise ClientError({"Error": {"Code": "NoSuchKey", "Message": "No such key"}}, "get_object")
|
||||||
|
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
mock_client = MagicMock()
|
mock_client = MagicMock()
|
||||||
mock_client.get_object.side_effect = side_effect
|
mock_client.get_object.side_effect = side_effect
|
||||||
|
@ -524,8 +527,8 @@ class ExportDataTest(MockEppLib):
|
||||||
# Create a CSV file in memory
|
# Create a CSV file in memory
|
||||||
csv_file = StringIO()
|
csv_file = StringIO()
|
||||||
writer = csv.writer(csv_file)
|
writer = csv.writer(csv_file)
|
||||||
# We use timezone.make_aware to sync to server time a datetime object with the current date (using date.today())
|
# We use timezone.make_aware to sync to server time a datetime object with the current date
|
||||||
# and a specific time (using datetime.min.time()).
|
# (using date.today()) and a specific time (using datetime.min.time()).
|
||||||
end_date = timezone.make_aware(datetime.combine(date.today() + timedelta(days=2), datetime.min.time()))
|
end_date = timezone.make_aware(datetime.combine(date.today() + timedelta(days=2), datetime.min.time()))
|
||||||
start_date = timezone.make_aware(datetime.combine(date.today() - timedelta(days=2), datetime.min.time()))
|
start_date = timezone.make_aware(datetime.combine(date.today() - timedelta(days=2), datetime.min.time()))
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TestProcessedMigrations(TestCase):
|
class TestProcessedMigrations(TestCase):
|
||||||
"""This test case class is designed to verify the idempotency of migrations
|
"""This test case class is designed to verify the idempotency of migrations
|
||||||
related to domain transitions in the application."""
|
related to domain transitions in the application."""
|
||||||
|
@ -241,8 +242,8 @@ class TestOrganizationMigration(TestCase):
|
||||||
execute the load_organization_data command with the specified arguments.
|
execute the load_organization_data command with the specified arguments.
|
||||||
"""
|
"""
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
# noqa here (E501) because splitting this up makes it
|
# noqa here (E501) because splitting this up makes it
|
||||||
# confusing to read.
|
# confusing to read.
|
||||||
with patch(
|
with patch(
|
||||||
"registrar.management.commands.utility.terminal_helper.TerminalHelper.query_yes_no_exit", # noqa
|
"registrar.management.commands.utility.terminal_helper.TerminalHelper.query_yes_no_exit", # noqa
|
||||||
return_value=True,
|
return_value=True,
|
||||||
|
@ -308,7 +309,8 @@ class TestOrganizationMigration(TestCase):
|
||||||
3. Checks that the data has been loaded as expected.
|
3. Checks that the data has been loaded as expected.
|
||||||
|
|
||||||
The expected result is a set of TransitionDomain objects with specific attributes.
|
The expected result is a set of TransitionDomain objects with specific attributes.
|
||||||
The test fetches the actual TransitionDomain objects from the database and compares them with the expected objects.
|
The test fetches the actual TransitionDomain objects from the database and compares them with
|
||||||
|
the expected objects.
|
||||||
"""
|
"""
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
# noqa - E501 (harder to read)
|
# noqa - E501 (harder to read)
|
||||||
|
@ -392,7 +394,9 @@ class TestOrganizationMigration(TestCase):
|
||||||
domain_information = DomainInformation.objects.filter(domain=_domain).get()
|
domain_information = DomainInformation.objects.filter(domain=_domain).get()
|
||||||
|
|
||||||
expected_creator = User.objects.filter(username="System").get()
|
expected_creator = User.objects.filter(username="System").get()
|
||||||
expected_ao = Contact.objects.filter(first_name="Seline", middle_name="testmiddle2", last_name="Tower").get()
|
expected_ao = Contact.objects.filter(
|
||||||
|
first_name="Seline", middle_name="testmiddle2", last_name="Tower"
|
||||||
|
).get()
|
||||||
expected_domain_information = DomainInformation(
|
expected_domain_information = DomainInformation(
|
||||||
creator=expected_creator,
|
creator=expected_creator,
|
||||||
organization_type="federal",
|
organization_type="federal",
|
||||||
|
@ -445,7 +449,9 @@ class TestOrganizationMigration(TestCase):
|
||||||
domain_information = DomainInformation.objects.filter(domain=_domain).get()
|
domain_information = DomainInformation.objects.filter(domain=_domain).get()
|
||||||
|
|
||||||
expected_creator = User.objects.filter(username="System").get()
|
expected_creator = User.objects.filter(username="System").get()
|
||||||
expected_ao = Contact.objects.filter(first_name="Seline", middle_name="testmiddle2", last_name="Tower").get()
|
expected_ao = Contact.objects.filter(
|
||||||
|
first_name="Seline", middle_name="testmiddle2", last_name="Tower"
|
||||||
|
).get()
|
||||||
expected_domain_information = DomainInformation(
|
expected_domain_information = DomainInformation(
|
||||||
creator=expected_creator,
|
creator=expected_creator,
|
||||||
organization_type="federal",
|
organization_type="federal",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue