lint and fixing merge problems

This commit is contained in:
David Kennedy 2024-02-26 19:32:35 -05:00
parent af849adbea
commit bd71317da3
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 11 additions and 82 deletions

View file

@ -902,7 +902,14 @@ class DomainApplicationAdmin(ListHeaderAdmin):
custom_election_board.short_description = "Election office" # type: ignore custom_election_board.short_description = "Election office" # type: ignore
# Filters # Filters
list_filter = ("status", "organization_type", "federal_type", ElectionOfficeFilter, "rejection_reason", InvestigatorFilter) list_filter = (
"status",
"organization_type",
"federal_type",
ElectionOfficeFilter,
"rejection_reason",
InvestigatorFilter,
)
# Search # Search
search_fields = [ search_fields = [

View file

@ -1223,87 +1223,6 @@ class TestDomainApplicationAdmin(MockEppLib):
# Assert that the status has not changed # Assert that the status has not changed
self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW) self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW)
def test_change_view_with_restricted_creator(self):
with less_console_noise():
# Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
application.creator.status = User.RESTRICTED
application.creator.save()
with patch("django.contrib.messages.warning") as mock_warning:
# Create a request object with a superuser
request = self.factory.get("/admin/your_app/domainapplication/{}/change/".format(application.pk))
request.user = self.superuser
self.admin.display_restricted_warning(request, application)
# Assert that the error message was called with the correct argument
mock_warning.assert_called_once_with(
request,
"Cannot edit an application with a restricted creator.",
)
self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_analyst(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path
request.user = self.staffuser
readonly_fields = self.admin.get_readonly_fields(request)
expected_fields = [
"creator",
"about_your_organization",
"requested_domain",
"approved_domain",
"alternative_domains",
"purpose",
"submitter",
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",
]
self.assertEqual(readonly_fields, expected_fields)
def test_readonly_fields_for_superuser(self):
with less_console_noise():
request = self.factory.get("/") # Use the correct method and path
request.user = self.superuser
readonly_fields = self.admin.get_readonly_fields(request)
expected_fields = []
self.assertEqual(readonly_fields, expected_fields)
def test_saving_when_restricted_creator(self):
with less_console_noise():
# Create an instance of the model
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
application.creator.status = User.RESTRICTED
application.creator.save()
# Create a request object with a superuser
request = self.factory.get("/")
request.user = self.superuser
with patch("django.contrib.messages.error") as mock_error:
# Simulate saving the model
self.admin.save_model(request, application, None, False)
# Assert that the error message was called with the correct argument
mock_error.assert_called_once_with(
request,
"This action is not permitted for applications with a restricted creator.",
)
# Assert that the status has not changed
self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW)
def test_change_view_with_restricted_creator(self): def test_change_view_with_restricted_creator(self):
with less_console_noise(): with less_console_noise():
# Create an instance of the model # Create an instance of the model

View file

@ -505,6 +505,7 @@ class TestDomainAvailable(MockEppLib):
return MagicMock( return MagicMock(
res_data=[responses.check.CheckDomainResultData(name="available.gov", avail=True, reason=None)], res_data=[responses.check.CheckDomainResultData(name="available.gov", avail=True, reason=None)],
) )
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()
@ -538,6 +539,7 @@ class TestDomainAvailable(MockEppLib):
return MagicMock( return MagicMock(
res_data=[responses.check.CheckDomainResultData(name="unavailable.gov", avail=False, reason="In Use")], res_data=[responses.check.CheckDomainResultData(name="unavailable.gov", avail=False, reason="In Use")],
) )
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()
@ -588,6 +590,7 @@ class TestDomainAvailable(MockEppLib):
def side_effect(_request, cleaned): def side_effect(_request, cleaned):
raise RegistryError(code=ErrorCode.COMMAND_SYNTAX_ERROR) raise RegistryError(code=ErrorCode.COMMAND_SYNTAX_ERROR)
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()