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
945abe72
Commit
945abe72
authored
Jul 28, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respond to code review feedback
parent
47b81c92
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
34 deletions
+10
-34
lms/djangoapps/verify_student/tests/test_views.py
+10
-34
No files found.
lms/djangoapps/verify_student/tests/test_views.py
View file @
945abe72
...
@@ -7,7 +7,6 @@ import json
...
@@ -7,7 +7,6 @@ import json
import
urllib
import
urllib
from
datetime
import
timedelta
,
datetime
from
datetime
import
timedelta
,
datetime
from
uuid
import
uuid4
from
uuid
import
uuid4
import
contextlib
import
ddt
import
ddt
import
httpretty
import
httpretty
...
@@ -1345,24 +1344,26 @@ class TestSubmitPhotosForVerification(TestCase):
...
@@ -1345,24 +1344,26 @@ class TestSubmitPhotosForVerification(TestCase):
"S3_BUCKET"
:
"test.example.com"
,
"S3_BUCKET"
:
"test.example.com"
,
}
}
})
})
@httpretty.activate
@moto.mock_s3
@moto.mock_s3
def
test_submit_photos_for_reverification
(
self
):
def
test_submit_photos_for_reverification
(
self
):
# Create the S3 bucket for photo upload
# Create the S3 bucket for photo upload
conn
=
boto
.
connect_s3
()
conn
=
boto
.
connect_s3
()
conn
.
create_bucket
(
"test.example.com"
)
conn
.
create_bucket
(
"test.example.com"
)
# Mock the POST to Software Secure
httpretty
.
register_uri
(
httpretty
.
POST
,
"https://verify.example.com/submit/"
)
# Submit an initial verification attempt
# Submit an initial verification attempt
with
self
.
_intercept_post
()
as
mock_post
:
self
.
_submit_photos
(
self
.
_submit_photos
(
face_image
=
self
.
IMAGE_DATA
+
"4567"
,
face_image
=
self
.
IMAGE_DATA
+
"4567"
,
photo_id_image
=
self
.
IMAGE_DATA
+
"8910"
,
photo_id_image
=
self
.
IMAGE_DATA
+
"8910"
,
)
)
initial_data
=
self
.
_get_post_data
(
mock_post
)
initial_data
=
self
.
_get_post_data
(
)
# Submit a face photo for re-verification
# Submit a face photo for re-verification
with
self
.
_intercept_post
()
as
mock_post
:
self
.
_submit_photos
(
face_image
=
self
.
IMAGE_DATA
+
"1112"
)
self
.
_submit_photos
(
face_image
=
self
.
IMAGE_DATA
+
"1112"
)
reverification_data
=
self
.
_get_post_data
(
mock_post
)
reverification_data
=
self
.
_get_post_data
(
)
# Verify that the initial attempt sent the same ID photo as the reverification attempt
# Verify that the initial attempt sent the same ID photo as the reverification attempt
self
.
assertEqual
(
initial_data
[
"PhotoIDKey"
],
reverification_data
[
"PhotoIDKey"
])
self
.
assertEqual
(
initial_data
[
"PhotoIDKey"
],
reverification_data
[
"PhotoIDKey"
])
...
@@ -1484,35 +1485,10 @@ class TestSubmitPhotosForVerification(TestCase):
...
@@ -1484,35 +1485,10 @@ class TestSubmitPhotosForVerification(TestCase):
account_settings
=
get_account_settings
(
self
.
user
)
account_settings
=
get_account_settings
(
self
.
user
)
self
.
assertEqual
(
account_settings
[
'name'
],
full_name
)
self
.
assertEqual
(
account_settings
[
'name'
],
full_name
)
@contextlib.contextmanager
def
_get_post_data
(
self
):
def
_intercept_post
(
self
):
"""Retrieve POST data from the last request. """
"""
last_request
=
httpretty
.
last_request
()
Mock `requests.post()` to always return a 200 status code.
return
json
.
loads
(
last_request
.
body
)
Yields:
mock.Mock
"""
with
patch
(
"verify_student.models.requests.post"
)
as
mock_post
:
mock_post
.
return_value
=
mock
.
Mock
(
status_code
=
200
,
text
=
"Fake response"
,
)
yield
mock_post
def
_get_post_data
(
self
,
mock_post
):
"""
Retrieve data sent with a mock POST request.
Arguments:
mock_post (mock.Mock): The mock for `requests.post()`.
Returns:
dict
"""
__
,
kwargs
=
mock_post
.
call_args
return
json
.
loads
(
kwargs
[
"data"
])
class
TestPhotoVerificationResultsCallback
(
ModuleStoreTestCase
):
class
TestPhotoVerificationResultsCallback
(
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