Commit fe88e60d by zubair-arbi

save the self referencing field 'copy_id_photo_from' for ICRV photo verifications + update test

parent 7e55437d
...@@ -663,10 +663,12 @@ class SoftwareSecurePhotoVerification(PhotoVerification): ...@@ -663,10 +663,12 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
@status_before_must_be("must_retry", "ready", "submitted") @status_before_must_be("must_retry", "ready", "submitted")
def submit(self, copy_id_photo_from=None): def submit(self, copy_id_photo_from=None):
""" """Submit our verification attempt to Software Secure for validation.
Submit our verification attempt to Software Secure for validation. This
will set our status to "submitted" if the post is successful, and This will set our status to "submitted" if the post is successful, and
"must_retry" if the post fails. "must_retry" if the post fails.
This will also set the self referencing field 'copy_id_photo_from' on
the software secure photo validation object.
Keyword Arguments: Keyword Arguments:
copy_id_photo_from (SoftwareSecurePhotoVerification): If provided, re-send the ID photo copy_id_photo_from (SoftwareSecurePhotoVerification): If provided, re-send the ID photo
...@@ -674,6 +676,12 @@ class SoftwareSecurePhotoVerification(PhotoVerification): ...@@ -674,6 +676,12 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
are sent with previously-submitted ID photos. are sent with previously-submitted ID photos.
""" """
if copy_id_photo_from:
# Update the field 'copy_id_photo_from' with provided software
# secure photo verification object
self.copy_id_photo_from = copy_id_photo_from
self.save()
try: try:
response = self.send_request(copy_id_photo_from=copy_id_photo_from) response = self.send_request(copy_id_photo_from=copy_id_photo_from)
if response.ok: if response.ok:
......
...@@ -484,9 +484,9 @@ class TestPhotoVerification(ModuleStoreTestCase): ...@@ -484,9 +484,9 @@ class TestPhotoVerification(ModuleStoreTestCase):
self.assertIs(result, None) self.assertIs(result, None)
# Make an initial verification with 'photo_id_key' # Make an initial verification with 'photo_id_key'
attempt = SoftwareSecurePhotoVerification(user=user, photo_id_key="dummy_photo_id_key") first_attempt = SoftwareSecurePhotoVerification(user=user, photo_id_key="dummy_photo_id_key")
attempt.status = 'approved' first_attempt.status = 'approved'
attempt.save() first_attempt.save()
# Check that method 'get_initial_verification' returns the correct # Check that method 'get_initial_verification' returns the correct
# initial verification attempt # initial verification attempt
...@@ -494,9 +494,11 @@ class TestPhotoVerification(ModuleStoreTestCase): ...@@ -494,9 +494,11 @@ class TestPhotoVerification(ModuleStoreTestCase):
self.assertIsNotNone(first_result) self.assertIsNotNone(first_result)
# Now create a second verification without 'photo_id_key' # Now create a second verification without 'photo_id_key'
attempt = SoftwareSecurePhotoVerification(user=user) second_attempt = SoftwareSecurePhotoVerification(user=user)
attempt.status = 'submitted' second_attempt.mark_ready()
attempt.save() # Parameter 'copy_id_photo_from' is used for reverification, in which
# new face photos are sent with previously-submitted ID photos
second_attempt.submit(copy_id_photo_from=first_result)
# Test method 'get_initial_verification' still returns the correct # Test method 'get_initial_verification' still returns the correct
# initial verification attempt which have 'photo_id_key' set # initial verification attempt which have 'photo_id_key' set
...@@ -504,6 +506,11 @@ class TestPhotoVerification(ModuleStoreTestCase): ...@@ -504,6 +506,11 @@ class TestPhotoVerification(ModuleStoreTestCase):
self.assertIsNotNone(second_result) self.assertIsNotNone(second_result)
self.assertEqual(second_result, first_result) self.assertEqual(second_result, first_result)
# Also verify that second photo verification has set self referencing field
# 'copy_id_photo_from' with initial verification
self.assertIsNotNone(second_attempt.copy_id_photo_from)
self.assertEqual(second_attempt.copy_id_photo_from, first_attempt)
@ddt.ddt @ddt.ddt
class VerificationCheckpointTest(ModuleStoreTestCase): class VerificationCheckpointTest(ModuleStoreTestCase):
......
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