Commit 02fc6a40 by David Ormsbee

Add model tests to verify_student flow.

parent 54ea98d2
...@@ -177,7 +177,7 @@ class PhotoVerification(StatusModel): ...@@ -177,7 +177,7 @@ class PhotoVerification(StatusModel):
@classmethod @classmethod
def user_is_verified(cls, user, earliest_allowed_date=None): def user_is_verified(cls, user, earliest_allowed_date=None):
""" """
Returns whether or not a user has satisfactorily proved their Return whether or not a user has satisfactorily proved their
identity. Depending on the policy, this can expire after some period of identity. Depending on the policy, this can expire after some period of
time, so a user might have to renew periodically. time, so a user might have to renew periodically.
""" """
...@@ -194,7 +194,11 @@ class PhotoVerification(StatusModel): ...@@ -194,7 +194,11 @@ class PhotoVerification(StatusModel):
@classmethod @classmethod
def user_has_valid_or_pending(cls, user, earliest_allowed_date=None): def user_has_valid_or_pending(cls, user, earliest_allowed_date=None):
""" """
TODO: eliminate duplication with user_is_verified Return whether the user has a complete verification attempt that is or
*might* be good. This means that it's approved, been submitted, or would
have been submitted but had an non-user error when it was being
submitted. It's basically any situation in which the user has signed off
on the contents of the attempt, and we have not yet received a denial.
""" """
valid_statuses = ['must_retry', 'submitted', 'approved'] valid_statuses = ['must_retry', 'submitted', 'approved']
earliest_allowed_date = ( earliest_allowed_date = (
...@@ -210,11 +214,8 @@ class PhotoVerification(StatusModel): ...@@ -210,11 +214,8 @@ class PhotoVerification(StatusModel):
@classmethod @classmethod
def active_for_user(cls, user): def active_for_user(cls, user):
""" """
Return all PhotoVerifications that are still active (i.e. not Return the most recent PhotoVerification that is marked ready (i.e. the
approved or denied). user has said they're set, but we haven't submitted anything yet).
Should there only be one active at any given time for a user? Enforced
at the DB level?
""" """
# This should only be one at the most, but just in case we create more # This should only be one at the most, but just in case we create more
# by mistake, we'll grab the most recently created one. # by mistake, we'll grab the most recently created one.
...@@ -361,7 +362,9 @@ class PhotoVerification(StatusModel): ...@@ -361,7 +362,9 @@ class PhotoVerification(StatusModel):
reviewing_service=""): reviewing_service=""):
""" """
Mark that this attempt could not be completed because of a system error. Mark that this attempt could not be completed because of a system error.
Status should be moved to `must_retry`. Status should be moved to `must_retry`. For example, if Software Secure
reported to us that they couldn't process our submission because they
couldn't decrypt the image we sent.
""" """
if self.status in ["approved", "denied"]: if self.status in ["approved", "denied"]:
return # If we were already approved or denied, just leave it. return # If we were already approved or denied, just leave it.
...@@ -480,6 +483,8 @@ class SoftwareSecurePhotoVerification(PhotoVerification): ...@@ -480,6 +483,8 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
self.save() self.save()
except Exception as error: except Exception as error:
log.exception(error) log.exception(error)
self.status = "must_retry"
self.save()
def image_url(self, name): def image_url(self, name):
""" """
...@@ -549,7 +554,13 @@ class SoftwareSecurePhotoVerification(PhotoVerification): ...@@ -549,7 +554,13 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
return headers, body return headers, body
def request_message_txt(self): def request_message_txt(self):
"""This is the body of the request we send across.""" """
This is the body of the request we send across. This is never actually
used in the code, but exists for debugging purposes -- you can call
`print attempt.request_message_txt()` on the console and get a readable
rendering of the request that would be sent across, without actually
sending anything.
"""
headers, body = self.create_request() headers, body = self.create_request()
header_txt = "\n".join( header_txt = "\n".join(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment