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
986b63d8
Commit
986b63d8
authored
Jun 24, 2013
by
Jean Manuel Nater
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed run_wrapped() and replaced its functionality with patch.dict():
parent
e44ef1a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
40 deletions
+29
-40
lms/djangoapps/courseware/tests/helpers.py
+4
-0
lms/djangoapps/courseware/tests/test_navigation.py
+0
-1
lms/djangoapps/courseware/tests/test_view_authentication.py
+25
-39
No files found.
lms/djangoapps/courseware/tests/helpers.py
View file @
986b63d8
...
...
@@ -44,6 +44,10 @@ def check_for_post_code(self, code, url, data={}):
class
LoginEnrollmentTestCase
(
TestCase
):
"""
Provides support for user creation,
activation, login, and course enrollment.
"""
def
setup_user
(
self
):
"""
...
...
lms/djangoapps/courseware/tests/test_navigation.py
View file @
986b63d8
...
...
@@ -21,7 +21,6 @@ class TestNavigation(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
self
.
course
=
CourseFactory
.
create
()
self
.
full
=
CourseFactory
.
create
(
display_name
=
'Robot_Sub_Course'
)
...
...
lms/djangoapps/courseware/tests/test_view_authentication.py
View file @
986b63d8
...
...
@@ -10,7 +10,7 @@ from django.test.utils import override_settings
# Need access to internal func to put users in the right group
from
courseware.access
import
(
has_access
,
_course_staff_group_name
,
course_beta_test_group_name
)
course_beta_test_group_name
,
settings
as
access_settings
)
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -20,6 +20,7 @@ from helpers import LoginEnrollmentTestCase, check_for_get_code
from
modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
#@patch.dict(access_settings.MITX_FEATURES, {'DISABLE_START_DATES': True})
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
TestViewAuth
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -81,20 +82,13 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
List of urls that students should be able to see before
launch.
`course` is an instance of CourseDescriptor.
"""
urls
=
self
.
_reverse_urls
([
'about_course'
],
course
)
urls
.
append
(
reverse
(
'courses'
))
return
urls
def
instructor_urls
(
self
,
course
):
"""
List of urls that only instructors/staff should be able to see.
"""
urls
=
self
.
_reverse_urls
([
'instructor_dashboard'
,
'gradebook'
,
'grade_summary'
],
course
)
return
urls
def
_check_non_staff_light
(
self
,
course
):
"""
Check that non-staff have access to light urls.
...
...
@@ -295,25 +289,12 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
Make sure that before course start, students can't access course
pages, but instructors can.
"""
self
.
run_wrapped
(
self
.
_do_test_dark_launch_enrolled_student
)
self
.
run_wrapped
(
self
.
_do_test_dark_launch_instructor
)
self
.
run_wrapped
(
self
.
_do_test_dark_launch_staff
)
def
test_enrollment_period
(
self
):
"""
Check that enrollment periods work.
"""
self
.
run_wrapped
(
self
.
_do_test_enrollment_period
)
# def test_beta_period(self):
# """
# Check that beta-test access works.
# """
# self.run_wrapped(self._do_test_beta_period)
def
_do_test_dark_launch_enrolled_student
(
self
):
@patch.dict
(
access_settings
.
MITX_FEATURES
,
{
'DISABLE_START_DATES'
:
False
})
def
test_dark_launch_enrolled_student
(
self
):
"""
Actually do the test, relying on settings to be right.
Make sure that before course start, students can't access course
pages.
"""
student_email
,
student_password
=
self
.
ACCOUNT_INFO
[
0
]
...
...
@@ -328,7 +309,6 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertFalse
(
self
.
course
.
has_started
())
self
.
assertFalse
(
self
.
full
.
has_started
())
self
.
assertFalse
(
settings
.
MITX_FEATURES
[
'DISABLE_START_DATES'
])
# First, try with an enrolled student
print
'=== Testing student access....'
...
...
@@ -342,7 +322,12 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
_check_non_staff_light
(
self
.
full
)
self
.
_check_non_staff_dark
(
self
.
full
)
def
_do_test_dark_launch_instructor
(
self
):
@patch.dict
(
access_settings
.
MITX_FEATURES
,
{
'DISABLE_START_DATES'
:
False
})
def
test_dark_launch_instructor
(
self
):
"""
Make sure that before course start instructors can access the
page for their course.
"""
instructor_email
,
instructor_password
=
self
.
ACCOUNT_INFO
[
1
]
...
...
@@ -369,7 +354,12 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
_check_non_staff_dark
(
self
.
full
)
self
.
_check_staff
(
self
.
course
)
def
_do_test_dark_launch_staff
(
self
):
@patch.dict
(
access_settings
.
MITX_FEATURES
,
{
'DISABLE_START_DATES'
:
False
})
def
test_dark_launch_staff
(
self
):
"""
Make sure that before course start staff can access
course pages.
"""
instructor_email
,
instructor_password
=
self
.
ACCOUNT_INFO
[
1
]
...
...
@@ -394,9 +384,10 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
_check_staff
(
self
.
course
)
self
.
_check_staff
(
self
.
full
)
def
_do_test_enrollment_period
(
self
):
@patch.dict
(
access_settings
.
MITX_FEATURES
,
{
'DISABLE_START_DATES'
:
False
})
def
test_enrollment_period
(
self
):
"""
Actually do the test, relying on settings to be right
.
Check that enrollment periods work
.
"""
student_email
,
student_password
=
self
.
ACCOUNT_INFO
[
0
]
...
...
@@ -447,20 +438,15 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
unenroll
(
self
.
course
)
self
.
assertTrue
(
self
.
enroll
(
self
.
course
))
#from courseware.access import MITX_FEATURES
#@patch.dict(MITX_FEATURES, {'DISABLE_START_DATES': True})
def
_do_test_beta_period
(
self
):
@patch.dict
(
access_settings
.
MITX_FEATURES
,
{
'DISABLE_START_DATES'
:
False
})
def
test_beta_period
(
self
):
"""
Actually test beta periods, relying on settings to be right
.
Check that beta-test access works
.
"""
student_email
,
student_password
=
self
.
ACCOUNT_INFO
[
0
]
instructor_email
,
instructor_password
=
self
.
ACCOUNT_INFO
[
1
]
# trust, but verify :)
self
.
assertFalse
(
settings
.
MITX_FEATURES
[
'DISABLE_START_DATES'
])
# Make courses start in the future
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
tomorrow
=
now
+
datetime
.
timedelta
(
days
=
1
)
...
...
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