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
f3149651
Commit
f3149651
authored
Oct 01, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for some of the new views.
parent
dd46eb47
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
5 deletions
+55
-5
lms/djangoapps/verify_student/tests/test_views.py
+51
-1
lms/envs/acceptance.py
+0
-4
lms/envs/test.py
+4
-0
No files found.
lms/djangoapps/verify_student/tests/test_views.py
View file @
f3149651
...
@@ -10,20 +10,30 @@ verify_student/start?course_id=MITx/6.002x/2013_Spring # create
...
@@ -10,20 +10,30 @@ verify_student/start?course_id=MITx/6.002x/2013_Spring # create
"""
"""
import
urllib
import
urllib
from
mock
import
patch
,
Mock
,
ANY
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.core.exceptions
import
ObjectDoesNotExist
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
from
verify_student.views
import
render_to_response
from
verify_student.models
import
SoftwareSecurePhotoVerification
def
mock_render_to_response
(
*
args
,
**
kwargs
):
return
render_to_response
(
*
args
,
**
kwargs
)
render_mock
=
Mock
(
side_effect
=
mock_render_to_response
)
class
StartView
(
TestCase
):
class
StartView
(
TestCase
):
def
start_url
(
course_id
=
""
):
def
start_url
(
self
,
course_id
=
""
):
return
"/verify_student/{0}"
.
format
(
urllib
.
quote
(
course_id
))
return
"/verify_student/{0}"
.
format
(
urllib
.
quote
(
course_id
))
def
test_start_new_verification
(
self
):
def
test_start_new_verification
(
self
):
...
@@ -58,3 +68,43 @@ class TestVerifyView(TestCase):
...
@@ -58,3 +68,43 @@ class TestVerifyView(TestCase):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
response
.
status_code
,
302
)
self
.
assertEquals
(
response
.
status_code
,
302
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
TestReverifyView
(
TestCase
):
"""
Tests for the reverification views
"""
def
setUp
(
self
):
self
.
user
=
UserFactory
.
create
(
username
=
"rusty"
,
password
=
"test"
)
self
.
client
.
login
(
username
=
"rusty"
,
password
=
"test"
)
@patch
(
'verify_student.views.render_to_response'
,
render_mock
)
def
test_reverify_get
(
self
):
url
=
reverse
(
'verify_student_reverify'
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
response
.
status_code
,
200
)
((
_template
,
context
),
_kwargs
)
=
render_mock
.
call_args
self
.
assertFalse
(
context
[
'error'
])
@patch
(
'verify_student.views.render_to_response'
,
render_mock
)
def
test_reverify_post_failure
(
self
):
url
=
reverse
(
'verify_student_reverify'
)
response
=
self
.
client
.
post
(
url
,
{
'face_image'
:
''
,
'photo_id_image'
:
''
})
self
.
assertEquals
(
response
.
status_code
,
200
)
((
template
,
context
),
_kwargs
)
=
render_mock
.
call_args
self
.
assertIn
(
'photo_reverification'
,
template
)
self
.
assertTrue
(
context
[
'error'
])
def
test_reverify_post_success
(
self
):
url
=
reverse
(
'verify_student_reverify'
)
response
=
self
.
client
.
post
(
url
,
{
'face_image'
:
','
,
'photo_id_image'
:
','
})
self
.
assertEquals
(
response
.
status_code
,
302
)
try
:
verification_attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
user
=
self
.
user
)
self
.
assertIsNotNone
(
verification_attempt
)
except
ObjectDoesNotExist
:
self
.
fail
(
'No verification object generated'
)
lms/envs/acceptance.py
View file @
f3149651
...
@@ -91,10 +91,6 @@ MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True
...
@@ -91,10 +91,6 @@ MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True
# Use the auto_auth workflow for creating users and logging them in
# Use the auto_auth workflow for creating users and logging them in
MITX_FEATURES
[
'AUTOMATIC_AUTH_FOR_TESTING'
]
=
True
MITX_FEATURES
[
'AUTOMATIC_AUTH_FOR_TESTING'
]
=
True
# Don't actually send any requests to Software Secure for student identity
# verification.
MITX_FEATURES
[
'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING'
]
=
True
# Enable fake payment processing page
# Enable fake payment processing page
MITX_FEATURES
[
'ENABLE_PAYMENT_FAKE'
]
=
True
MITX_FEATURES
[
'ENABLE_PAYMENT_FAKE'
]
=
True
...
...
lms/envs/test.py
View file @
f3149651
...
@@ -36,6 +36,10 @@ MITX_FEATURES['ENABLE_INSTRUCTOR_BETA_DASHBOARD'] = True
...
@@ -36,6 +36,10 @@ MITX_FEATURES['ENABLE_INSTRUCTOR_BETA_DASHBOARD'] = True
MITX_FEATURES
[
'ENABLE_SHOPPING_CART'
]
=
True
MITX_FEATURES
[
'ENABLE_SHOPPING_CART'
]
=
True
# Don't actually send any requests to Software Secure for student identity
# verification.
MITX_FEATURES
[
'AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING'
]
=
True
# Need wiki for courseware views to work. TODO (vshnayder): shouldn't need it.
# Need wiki for courseware views to work. TODO (vshnayder): shouldn't need it.
WIKI_ENABLED
=
True
WIKI_ENABLED
=
True
...
...
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