Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
beacf3c9
Commit
beacf3c9
authored
Feb 23, 2016
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only return unexpired initial verifications.
parent
a1a58db9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
lms/djangoapps/verify_student/models.py
+7
-3
lms/djangoapps/verify_student/tests/test_models.py
+23
-6
No files found.
lms/djangoapps/verify_student/models.py
View file @
beacf3c9
...
...
@@ -593,18 +593,22 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
copy_id_photo_from
=
models
.
ForeignKey
(
"self"
,
null
=
True
,
blank
=
True
)
@classmethod
def
get_initial_verification
(
cls
,
user
):
def
get_initial_verification
(
cls
,
user
,
earliest_allowed_date
=
None
):
"""Get initial verification for a user with the 'photo_id_key'.
Arguments:
user(User): user object
earliest_allowed_date(datetime): override expiration date for initial verification
Return:
SoftwareSecurePhotoVerification (object)
SoftwareSecurePhotoVerification (object)
or None
"""
init_verification
=
cls
.
objects
.
filter
(
user
=
user
,
status__in
=
[
"submitted"
,
"approved"
]
status__in
=
[
"submitted"
,
"approved"
],
created_at__gte
=
(
earliest_allowed_date
or
cls
.
_earliest_allowed_date
()
)
)
.
exclude
(
photo_id_key
=
''
)
return
init_verification
.
latest
(
'created_at'
)
if
init_verification
.
exists
()
else
None
...
...
lms/djangoapps/verify_student/tests/test_models.py
View file @
beacf3c9
# -*- coding: utf-8 -*-
from
datetime
import
timedelta
,
datetime
import
ddt
import
json
import
mock
import
requests.exceptions
import
pytz
import
ddt
from
django.conf
import
settings
from
django.db
import
IntegrityError
from
django.test
import
TestCase
from
freezegun
import
freeze_time
import
mock
from
mock
import
patch
from
nose.tools
import
assert_is_none
,
assert_equals
,
assert_raises
,
assert_true
,
assert_false
# pylint: disable=no-name-in-module
import
pytz
import
requests.exceptions
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -42,8 +43,9 @@ iwIDAQAB
"API_URL"
:
"http://localhost/verify_student/fake_endpoint"
,
"AWS_ACCESS_KEY"
:
"FAKEACCESSKEY"
,
"AWS_SECRET_KEY"
:
"FAKESECRETKEY"
,
"S3_BUCKET"
:
"fake-bucket"
}
"S3_BUCKET"
:
"fake-bucket"
,
},
"DAYS_GOOD_FOR"
:
10
,
}
...
...
@@ -524,6 +526,21 @@ class TestPhotoVerification(ModuleStoreTestCase):
self
.
assertIsNotNone
(
second_result
)
self
.
assertEqual
(
second_result
,
first_result
)
# Test method 'get_initial_verification' returns None after expiration
expired_future
=
datetime
.
utcnow
()
+
timedelta
(
days
=
(
FAKE_SETTINGS
[
'DAYS_GOOD_FOR'
]
+
1
))
with
freeze_time
(
expired_future
):
third_result
=
SoftwareSecurePhotoVerification
.
get_initial_verification
(
user
)
self
.
assertIsNone
(
third_result
)
# Test method 'get_initial_verification' returns correct attempt after system expiration,
# but within earliest allowed override.
expired_future
=
datetime
.
utcnow
()
+
timedelta
(
days
=
(
FAKE_SETTINGS
[
'DAYS_GOOD_FOR'
]
+
1
))
earliest_allowed
=
datetime
.
utcnow
()
-
timedelta
(
days
=
1
)
with
freeze_time
(
expired_future
):
fourth_result
=
SoftwareSecurePhotoVerification
.
get_initial_verification
(
user
,
earliest_allowed
)
self
.
assertIsNotNone
(
fourth_result
)
self
.
assertEqual
(
fourth_result
,
first_result
)
@ddt.ddt
class
VerificationCheckpointTest
(
ModuleStoreTestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment