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
3938e84d
Commit
3938e84d
authored
Feb 10, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2526 from edx/db/refactor-student-view
Refactor student views
parents
6635233b
1dfd3310
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
common/djangoapps/student/tests/test_login.py
+6
-1
common/djangoapps/student/tests/tests.py
+23
-11
common/djangoapps/student/views.py
+0
-0
No files found.
common/djangoapps/student/tests/test_login.py
View file @
3938e84d
...
...
@@ -23,6 +23,7 @@ from external_auth.models import ExternalAuthMap
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
settings
.
COMMON_TEST_DATA_ROOT
,
{})
class
LoginTest
(
TestCase
):
'''
Test student.views.login_user() view
...
...
@@ -224,7 +225,11 @@ class ExternalAuthShibTest(ModuleStoreTestCase):
"""
response
=
self
.
client
.
post
(
reverse
(
'login'
),
{
'email'
:
self
.
user_w_map
.
email
,
'password'
:
''
})
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
json
.
dumps
({
'success'
:
False
,
'redirect'
:
reverse
(
'shib-login'
)}))
obj
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
obj
,
{
'success'
:
False
,
'redirect'
:
reverse
(
'shib-login'
),
})
@unittest.skipUnless
(
settings
.
FEATURES
.
get
(
'AUTH_USE_SHIB'
),
"AUTH_USE_SHIB not set"
)
def
test__get_course_enrollment_domain
(
self
):
...
...
common/djangoapps/student/tests/tests.py
View file @
3938e84d
...
...
@@ -68,8 +68,11 @@ class ResetPasswordTests(TestCase):
bad_pwd_resp
=
password_reset
(
bad_pwd_req
)
# If they've got an unusable password, we return a successful response code
self
.
assertEquals
(
bad_pwd_resp
.
status_code
,
200
)
self
.
assertEquals
(
bad_pwd_resp
.
content
,
json
.
dumps
({
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
}))
obj
=
json
.
loads
(
bad_pwd_resp
.
content
)
self
.
assertEquals
(
obj
,
{
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
,
})
@patch
(
'student.views.render_to_string'
,
Mock
(
side_effect
=
mock_render_to_string
,
autospec
=
True
))
def
test_nonexist_email_password_reset
(
self
):
...
...
@@ -80,12 +83,19 @@ class ResetPasswordTests(TestCase):
# Note: even if the email is bad, we return a successful response code
# This prevents someone potentially trying to "brute-force" find out which emails are and aren't registered with edX
self
.
assertEquals
(
bad_email_resp
.
status_code
,
200
)
self
.
assertEquals
(
bad_email_resp
.
content
,
json
.
dumps
({
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
}))
@unittest.skipIf
(
settings
.
FEATURES
.
get
(
'DISABLE_RESET_EMAIL_TEST'
,
False
),
dedent
(
"""Skipping Test because CMS has not provided necessary templates for password reset.
If LMS tests print this message, that needs to be fixed."""
))
obj
=
json
.
loads
(
bad_email_resp
.
content
)
self
.
assertEquals
(
obj
,
{
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
,
})
@unittest.skipIf
(
settings
.
FEATURES
.
get
(
'DISABLE_RESET_EMAIL_TEST'
,
False
),
dedent
(
"""
Skipping Test because CMS has not provided necessary templates for password reset.
If LMS tests print this message, that needs to be fixed.
"""
)
)
@patch
(
'django.core.mail.send_mail'
)
@patch
(
'student.views.render_to_string'
,
Mock
(
side_effect
=
mock_render_to_string
,
autospec
=
True
))
def
test_reset_password_email
(
self
,
send_email
):
...
...
@@ -94,9 +104,11 @@ class ResetPasswordTests(TestCase):
good_req
=
self
.
request_factory
.
post
(
'/password_reset/'
,
{
'email'
:
self
.
user
.
email
})
good_resp
=
password_reset
(
good_req
)
self
.
assertEquals
(
good_resp
.
status_code
,
200
)
self
.
assertEquals
(
good_resp
.
content
,
json
.
dumps
({
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
}))
obj
=
json
.
loads
(
good_resp
.
content
)
self
.
assertEquals
(
obj
,
{
'success'
:
True
,
'value'
:
"('registration/password_reset_done.html', [])"
,
})
((
subject
,
msg
,
from_addr
,
to_addrs
),
sm_kwargs
)
=
send_email
.
call_args
self
.
assertIn
(
"Password reset"
,
subject
)
...
...
common/djangoapps/student/views.py
View file @
3938e84d
This diff is collapsed.
Click to expand it.
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