Skip to content
Snippets Groups Projects
Unverified Commit 889f5e4e authored by Farhanah Sheets's avatar Farhanah Sheets Committed by GitHub
Browse files

Merge pull request #21212 from edx/fsheets/PROD-500

Fix: Do not compare Software Secure expiry_date when NULL
parents 99868f9f fed53227
Branches
Tags release-2020-04-16-15.19
No related merge requests found
......@@ -943,7 +943,10 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
Returns:
SoftwareSecurePhotoVerification (object) or None
"""
recent_verification = SoftwareSecurePhotoVerification.objects.filter(status='approved', user_id=user.id)
recent_verification = SoftwareSecurePhotoVerification.objects.filter(status='approved',
user_id=user.id,
expiry_date__isnull=False)
return recent_verification.latest('updated_at') if recent_verification.exists() else None
@classmethod
......
# -*- coding: utf-8 -*-
import json
from datetime import timedelta
from datetime import datetime, timedelta
import boto
import ddt
......@@ -380,6 +380,7 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase):
# Make an approved verification
attempt = SoftwareSecurePhotoVerification(user=user)
attempt.status = 'approved'
attempt.expiry_date = datetime.now()
attempt.save()
# Test method 'get_recent_verification' returns the most recent
......@@ -388,6 +389,25 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase):
self.assertIsNotNone(recent_verification)
self.assertEqual(recent_verification.id, attempt.id)
def test_get_recent_verification_expiry_null(self):
"""Test that method 'get_recent_verification' of model
'SoftwareSecurePhotoVerification' will return None when expiry_date
is NULL for 'approved' verifications based on updated_at value.
"""
user = UserFactory.create()
attempt = None
for _ in range(2):
# Make an approved verification
attempt = SoftwareSecurePhotoVerification(user=user)
attempt.status = 'approved'
attempt.save()
# Test method 'get_recent_verification' returns None
# as attempts don't have an expiry_date
recent_verification = SoftwareSecurePhotoVerification.get_recent_verification(user=user)
self.assertIsNone(recent_verification)
def test_no_approved_verification(self):
"""Test that method 'get_recent_verification' of model
'SoftwareSecurePhotoVerification' returns None if no
......
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