mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Linting, unit tests
This commit is contained in:
parent
02e0d00544
commit
25a5cd0226
4 changed files with 18 additions and 22 deletions
|
@ -188,7 +188,7 @@ class DomainApplicationFixture:
|
||||||
# This bundles them all together, and then saves it in a single call.
|
# This bundles them all together, and then saves it in a single call.
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
cls._create_applications(users)
|
cls._create_applications(users)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _create_applications(cls, users):
|
def _create_applications(cls, users):
|
||||||
"""Creates DomainApplications given a list of users"""
|
"""Creates DomainApplications given a list of users"""
|
||||||
|
@ -245,4 +245,4 @@ class DomainFixture(DomainApplicationFixture):
|
||||||
application.investigator = random.choice(users)
|
application.investigator = random.choice(users)
|
||||||
|
|
||||||
application.approve(send_email=False)
|
application.approve(send_email=False)
|
||||||
application.save()
|
application.save()
|
||||||
|
|
|
@ -190,8 +190,8 @@ class UserFixture:
|
||||||
# Lumped under .atomic to ensure we don't make redundant DB calls.
|
# Lumped under .atomic to ensure we don't make redundant DB calls.
|
||||||
# This bundles them all together, and then saves it in a single call.
|
# This bundles them all together, and then saves it in a single call.
|
||||||
# This is slightly different then bulk_create or bulk_update, in that
|
# This is slightly different then bulk_create or bulk_update, in that
|
||||||
# you still get the same behaviour of .save(), but those incremental
|
# you still get the same behaviour of .save(), but those incremental
|
||||||
# steps now do not need to close/reopen a db connection,
|
# steps now do not need to close/reopen a db connection,
|
||||||
# instead they share one.
|
# instead they share one.
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
cls.load_users(cls, cls.ADMINS, "full_access_group")
|
cls.load_users(cls, cls.ADMINS, "full_access_group")
|
||||||
|
|
|
@ -562,11 +562,11 @@ def completed_application(
|
||||||
)
|
)
|
||||||
if not investigator:
|
if not investigator:
|
||||||
investigator, _ = User.objects.get_or_create(
|
investigator, _ = User.objects.get_or_create(
|
||||||
username="incrediblyfakeinvestigator",
|
username="incrediblyfakeinvestigator",
|
||||||
first_name = "Joe",
|
first_name="Joe",
|
||||||
last_name = "Bob"
|
last_name="Bob",
|
||||||
is_staff=True
|
is_staff=True,
|
||||||
)
|
)
|
||||||
domain_application_kwargs = dict(
|
domain_application_kwargs = dict(
|
||||||
organization_type="federal",
|
organization_type="federal",
|
||||||
federal_type="executive",
|
federal_type="executive",
|
||||||
|
|
|
@ -70,23 +70,25 @@ class GenericError(Exception):
|
||||||
def get_error_message(self, code=None):
|
def get_error_message(self, code=None):
|
||||||
return self._error_mapping.get(code)
|
return self._error_mapping.get(code)
|
||||||
|
|
||||||
# (Q for reviewers) What should this be called?
|
|
||||||
|
# (Q for reviewers) What should this be called?
|
||||||
# Not a fan of this name.
|
# Not a fan of this name.
|
||||||
class FSMErrorCodes(IntEnum):
|
class FSMErrorCodes(IntEnum):
|
||||||
"""Used when doing FSM transitions.
|
"""Used when doing FSM transitions.
|
||||||
Overview of generic error codes:
|
Overview of generic error codes:
|
||||||
- 1 APPROVE_DOMAIN_IN_USE The domain is already in use
|
- 1 APPROVE_DOMAIN_IN_USE The domain is already in use
|
||||||
- 2 APPROVE_NO_INVESTIGATOR No investigator is assigned when approving
|
- 2 APPROVE_NO_INVESTIGATOR No investigator is assigned when approving
|
||||||
- 3 APPROVE_INVESTIGATOR_NOT_STAFF Investigator is a non-staff user
|
- 3 APPROVE_INVESTIGATOR_NOT_STAFF Investigator is a non-staff user
|
||||||
- 4 APPROVE_INVESTIGATOR_NOT_SUBMITTER The form submitter is not the investigator
|
- 4 APPROVE_INVESTIGATOR_NOT_SUBMITTER The form submitter is not the investigator
|
||||||
"""
|
"""
|
||||||
|
|
||||||
APPROVE_DOMAIN_IN_USE = 1
|
APPROVE_DOMAIN_IN_USE = 1
|
||||||
APPROVE_NO_INVESTIGATOR = 2
|
APPROVE_NO_INVESTIGATOR = 2
|
||||||
APPROVE_INVESTIGATOR_NOT_STAFF = 3
|
APPROVE_INVESTIGATOR_NOT_STAFF = 3
|
||||||
APPROVE_INVESTIGATOR_NOT_SUBMITTER = 4
|
APPROVE_INVESTIGATOR_NOT_SUBMITTER = 4
|
||||||
|
|
||||||
|
|
||||||
# (Q for reviewers) What should this be called?
|
# (Q for reviewers) What should this be called?
|
||||||
# Not a fan of this name.
|
# Not a fan of this name.
|
||||||
class ApplicationStatusError(Exception):
|
class ApplicationStatusError(Exception):
|
||||||
"""
|
"""
|
||||||
|
@ -95,18 +97,12 @@ class ApplicationStatusError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_error_mapping = {
|
_error_mapping = {
|
||||||
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: (
|
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("Cannot approve. Requested domain is already in use."),
|
||||||
"Cannot approve. Requested domain is already in use."
|
FSMErrorCodes.APPROVE_NO_INVESTIGATOR: ("Cannot approve. No investigator was assigned."),
|
||||||
),
|
FSMErrorCodes.APPROVE_INVESTIGATOR_NOT_STAFF: ("Cannot approve. Investigator is not a staff user."),
|
||||||
FSMErrorCodes.APPROVE_NO_INVESTIGATOR: (
|
|
||||||
"Cannot approve. No investigator was assigned."
|
|
||||||
),
|
|
||||||
FSMErrorCodes.APPROVE_INVESTIGATOR_NOT_STAFF: (
|
|
||||||
"Cannot approve. Investigator is not a staff user."
|
|
||||||
),
|
|
||||||
FSMErrorCodes.APPROVE_INVESTIGATOR_NOT_SUBMITTER: (
|
FSMErrorCodes.APPROVE_INVESTIGATOR_NOT_SUBMITTER: (
|
||||||
"Cannot approve. Only the assigned investigator can approve this application."
|
"Cannot approve. Only the assigned investigator can approve this application."
|
||||||
)
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, code=None, **kwargs):
|
def __init__(self, *args, code=None, **kwargs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue