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
39105f76
Commit
39105f76
authored
Nov 08, 2013
by
Julia Hansbrough
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1598 from edx/flowerhack/feature/command-retry-cert-submissions
Command for retrying failed photo verifications
parents
b72604d2
3c7afb69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
0 deletions
+82
-0
lms/djangoapps/verify_student/management/__init__.py
+0
-0
lms/djangoapps/verify_student/management/commands/__init__.py
+0
-0
lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py
+23
-0
lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py
+59
-0
No files found.
lms/djangoapps/verify_student/management/__init__.py
0 → 100644
View file @
39105f76
lms/djangoapps/verify_student/management/commands/__init__.py
0 → 100644
View file @
39105f76
lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py
0 → 100644
View file @
39105f76
"""
Django admin commands related to verify_student
"""
from
verify_student.models
import
SoftwareSecurePhotoVerification
from
django.core.management.base
import
BaseCommand
class
Command
(
BaseCommand
):
"""
This method finds those PhotoVerifications with a status of
MUST_RETRY and attempts to verify them.
"""
help
=
'Retries SoftwareSecurePhotoVerifications that are in a state of
\'
must_retry
\'
'
def
handle
(
self
,
*
args
,
**
options
):
attempts_to_retry
=
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
'must_retry'
)
print
(
"Attempting to retry {0} failed PhotoVerification submissions"
.
format
(
len
(
attempts_to_retry
)))
for
index
,
attempt
in
enumerate
(
attempts_to_retry
):
print
(
"Retrying submission #{0} (ID: {1}, User: {2})"
.
format
(
index
,
attempt
.
id
,
attempt
.
user
))
attempt
.
submit
()
print
(
"Retry result: {0}"
.
format
(
attempt
.
status
))
print
(
"Done resubmitting failed photo verifications"
)
lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py
0 → 100644
View file @
39105f76
"""
Tests for django admin commands in the verify_student module
Lots of imports from verify_student's model tests, since they cover similar ground
"""
from
nose.tools
import
(
assert_equals
,
assert_true
)
from
mock
import
patch
from
django.test
import
TestCase
from
django.conf
import
settings
import
requests
from
student.tests.factories
import
UserFactory
from
verify_student.models
import
SoftwareSecurePhotoVerification
from
django.core.management
import
call_command
from
verify_student.tests.test_models
import
MockKey
,
MockBucket
,
MockS3Connection
,
mock_software_secure_post
,
mock_software_secure_post_error
,
FAKE_SETTINGS
# Lots of patching to stub in our own settings, S3 substitutes, and HTTP posting
@patch.dict
(
settings
.
VERIFY_STUDENT
,
FAKE_SETTINGS
)
@patch
(
'verify_student.models.S3Connection'
,
new
=
MockS3Connection
)
@patch
(
'verify_student.models.Key'
,
new
=
MockKey
)
@patch
(
'verify_student.models.requests.post'
,
new
=
mock_software_secure_post
)
class
TestVerifyStudentCommand
(
TestCase
):
"""
Tests for django admin commands in the verify_student module
"""
def
create_and_submit
(
self
,
username
):
"""
Helper method that lets us create new SoftwareSecurePhotoVerifications
"""
user
=
UserFactory
.
create
()
attempt
=
SoftwareSecurePhotoVerification
(
user
=
user
)
user
.
profile
.
name
=
username
attempt
.
upload_face_image
(
"Fake Data"
)
attempt
.
upload_photo_id_image
(
"More Fake Data"
)
attempt
.
mark_ready
()
attempt
.
submit
()
return
attempt
def
test_retry_failed_photo_verifications
(
self
):
"""
Tests that the task used to find "must_retry" SoftwareSecurePhotoVerifications
and re-submit them executes successfully
"""
# set up some fake data to use...
self
.
create_and_submit
(
"SuccessfulSally"
)
with
patch
(
'verify_student.models.requests.post'
,
new
=
mock_software_secure_post_error
):
self
.
create_and_submit
(
"RetryRoger"
)
with
patch
(
'verify_student.models.requests.post'
,
new
=
mock_software_secure_post_error
):
self
.
create_and_submit
(
"RetryRick"
)
# check to make sure we had two successes and two failures; otherwise we've got problems elsewhere
assert_equals
(
len
(
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
"submitted"
)),
1
)
assert_equals
(
len
(
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
'must_retry'
)),
2
)
call_command
(
'retry_failed_photo_verifications'
)
attempts_to_retry
=
SoftwareSecurePhotoVerification
.
objects
.
filter
(
status
=
'must_retry'
)
assert_equals
(
bool
(
attempts_to_retry
),
False
)
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