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
ad9498ec
Commit
ad9498ec
authored
Feb 05, 2016
by
Toby Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to SharedModuleStoreTestCase in the 'courseware' app where possible.
parent
9ae0dada
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
400 additions
and
287 deletions
+400
-287
lms/djangoapps/courseware/tests/test_about.py
+71
-49
lms/djangoapps/courseware/tests/test_course_info.py
+16
-8
lms/djangoapps/courseware/tests/test_course_survey.py
+19
-17
lms/djangoapps/courseware/tests/test_credit_requirements.py
+8
-4
lms/djangoapps/courseware/tests/test_field_overrides.py
+1
-1
lms/djangoapps/courseware/tests/test_grades.py
+63
-46
lms/djangoapps/courseware/tests/test_lti_integration.py
+24
-20
lms/djangoapps/courseware/tests/test_masquerade.py
+24
-24
lms/djangoapps/courseware/tests/test_microsites.py
+16
-22
lms/djangoapps/courseware/tests/test_middleware.py
+7
-4
lms/djangoapps/courseware/tests/test_module_render.py
+67
-28
lms/djangoapps/courseware/tests/test_navigation.py
+23
-19
lms/djangoapps/courseware/tests/test_split_module.py
+28
-21
lms/djangoapps/courseware/tests/test_submitting_problems.py
+3
-6
lms/djangoapps/courseware/tests/test_tabs.py
+30
-18
No files found.
lms/djangoapps/courseware/tests/test_about.py
View file @
ad9498ec
...
@@ -41,29 +41,34 @@ SHIB_ERROR_STR = "The currently logged-in user account does not have permission
...
@@ -41,29 +41,34 @@ SHIB_ERROR_STR = "The currently logged-in user account does not have permission
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
AboutTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
,
EventTrackingTestCase
,
MilestonesTestCaseMixin
):
class
AboutTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
,
EventTrackingTestCase
,
MilestonesTestCaseMixin
):
"""
"""
Tests about xblock.
Tests about xblock.
"""
"""
def
setUp
(
self
):
super
(
AboutTestCase
,
self
)
.
setUp
()
@classmethod
self
.
course
=
CourseFactory
.
create
()
def
setUpClass
(
cls
):
self
.
about
=
ItemFactory
.
create
(
super
(
AboutTestCase
,
cls
)
.
setUpClass
()
category
=
"about"
,
parent_location
=
self
.
course
.
location
,
cls
.
course
=
CourseFactory
.
create
()
cls
.
course_without_about
=
CourseFactory
.
create
(
catalog_visibility
=
CATALOG_VISIBILITY_NONE
)
cls
.
course_with_about
=
CourseFactory
.
create
(
catalog_visibility
=
CATALOG_VISIBILITY_ABOUT
)
cls
.
purchase_course
=
CourseFactory
.
create
(
org
=
'MITx'
,
number
=
'buyme'
,
display_name
=
'Course To Buy'
)
cls
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
cls
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
)
)
self
.
course_without_about
=
CourseFactory
.
create
(
catalog_visibility
=
CATALOG_VISIBILITY_NONE
)
cls
.
about
=
ItemFactory
.
create
(
self
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
cls
.
course_without_about
.
location
,
category
=
"about"
,
parent_location
=
self
.
course_without_about
.
location
,
data
=
"WITHOUT ABOUT"
,
display_name
=
"overview"
data
=
"WITHOUT ABOUT"
,
display_name
=
"overview"
)
)
self
.
course_with_about
=
CourseFactory
.
create
(
catalog_visibility
=
CATALOG_VISIBILITY_ABOUT
)
cls
.
about
=
ItemFactory
.
create
(
self
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
cls
.
course_with_about
.
location
,
category
=
"about"
,
parent_location
=
self
.
course_with_about
.
location
,
data
=
"WITH ABOUT"
,
display_name
=
"overview"
data
=
"WITH ABOUT"
,
display_name
=
"overview"
)
)
self
.
purchase_course
=
CourseFactory
.
create
(
org
=
'MITx'
,
number
=
'buyme'
,
display_name
=
'Course To Buy'
)
def
setUp
(
self
):
super
(
AboutTestCase
,
self
)
.
setUp
()
self
.
course_mode
=
CourseMode
(
self
.
course_mode
=
CourseMode
(
course_id
=
self
.
purchase_course
.
id
,
course_id
=
self
.
purchase_course
.
id
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
...
@@ -152,7 +157,7 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, EventTrackingT
...
@@ -152,7 +157,7 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, EventTrackingT
def
test_about_page_unfulfilled_prereqs
(
self
):
def
test_about_page_unfulfilled_prereqs
(
self
):
pre_requisite_course
=
CourseFactory
.
create
(
pre_requisite_course
=
CourseFactory
.
create
(
org
=
'edX'
,
org
=
'edX'
,
course
=
'90
0
'
,
course
=
'90
1
'
,
display_name
=
'pre requisite course'
,
display_name
=
'pre requisite course'
,
)
)
...
@@ -222,21 +227,24 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
...
@@ -222,21 +227,24 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
AboutWithCappedEnrollmentsTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
AboutWithCappedEnrollmentsTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
This test case will check the About page when a course has a capped enrollment
This test case will check the About page when a course has a capped enrollment
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
AboutWithCappedEnrollmentsTestCase
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
metadata
=
{
"max_student_enrollments_allowed"
:
1
})
cls
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
cls
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
)
def
setUp
(
self
):
def
setUp
(
self
):
"""
"""
Set up the tests
Set up the tests
"""
"""
super
(
AboutWithCappedEnrollmentsTestCase
,
self
)
.
setUp
()
super
(
AboutWithCappedEnrollmentsTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
metadata
=
{
"max_student_enrollments_allowed"
:
1
})
self
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
self
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
)
def
test_enrollment_cap
(
self
):
def
test_enrollment_cap
(
self
):
"""
"""
...
@@ -272,20 +280,22 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTes
...
@@ -272,20 +280,22 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTes
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
AboutWithInvitationOnly
(
ModuleStoreTestCase
):
class
AboutWithInvitationOnly
(
Shared
ModuleStoreTestCase
):
"""
"""
This test case will check the About page when a course is invitation only.
This test case will check the About page when a course is invitation only.
"""
"""
def
setUp
(
self
):
@classmethod
super
(
AboutWithInvitationOnly
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
super
(
AboutWithInvitationOnly
,
cls
)
.
setUpClass
()
self
.
course
=
CourseFactory
.
create
(
metadata
=
{
"invitation_only"
:
True
})
cls
.
course
=
CourseFactory
.
create
(
metadata
=
{
"invitation_only"
:
True
})
cls
.
about
=
ItemFactory
.
create
(
self
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
cls
.
course
.
location
,
category
=
"about"
,
parent_location
=
self
.
course
.
location
,
display_name
=
"overview"
display_name
=
"overview"
)
)
def
setUp
(
self
):
super
(
AboutWithInvitationOnly
,
self
)
.
setUp
()
def
test_invitation_only
(
self
):
def
test_invitation_only
(
self
):
"""
"""
Test for user not logged in, invitation only course.
Test for user not logged in, invitation only course.
...
@@ -320,19 +330,22 @@ class AboutWithInvitationOnly(ModuleStoreTestCase):
...
@@ -320,19 +330,22 @@ class AboutWithInvitationOnly(ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.dict
(
settings
.
FEATURES
,
{
'RESTRICT_ENROLL_BY_REG_METHOD'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'RESTRICT_ENROLL_BY_REG_METHOD'
:
True
})
class
AboutTestCaseShibCourse
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
AboutTestCaseShibCourse
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
"""
"""
def
setUp
(
self
):
@classmethod
super
(
AboutTestCaseShibCourse
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
s
elf
.
course
=
CourseFactory
.
create
(
enrollment_domain
=
"shib:https://idp.stanford.edu/"
)
s
uper
(
AboutTestCaseShibCourse
,
cls
)
.
setUpClass
(
)
cls
.
course
=
CourseFactory
.
create
(
enrollment_domain
=
"shib:https://idp.stanford.edu/"
)
self
.
about
=
ItemFactory
.
create
(
cls
.
about
=
ItemFactory
.
create
(
category
=
"about"
,
parent_location
=
self
.
course
.
location
,
category
=
"about"
,
parent_location
=
cls
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
data
=
"OOGIE BLOOGIE"
,
display_name
=
"overview"
)
)
def
setUp
(
self
):
super
(
AboutTestCaseShibCourse
,
self
)
.
setUp
()
def
test_logged_in_shib_course
(
self
):
def
test_logged_in_shib_course
(
self
):
"""
"""
For shib courses, logged in users will see the enroll button, but get rejected once they click there
For shib courses, logged in users will see the enroll button, but get rejected once they click there
...
@@ -366,8 +379,8 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
...
@@ -366,8 +379,8 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
set but it is currently outside of that period.
set but it is currently outside of that period.
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
AboutWithClosedEnrollment
,
self
)
.
setUp
()
super
(
AboutWithClosedEnrollment
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
metadata
=
{
"invitation_only"
:
False
})
self
.
course
=
CourseFactory
.
create
(
metadata
=
{
"invitation_only"
:
False
})
# Setup enrollment period to be in future
# Setup enrollment period to be in future
...
@@ -385,7 +398,6 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
...
@@ -385,7 +398,6 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
)
)
def
test_closed_enrollmement
(
self
):
def
test_closed_enrollmement
(
self
):
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course
.
id
.
to_deprecated_string
()])
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course
.
id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
)
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
...
@@ -406,15 +418,32 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
...
@@ -406,15 +418,32 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SHOPPING_CART'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SHOPPING_CART'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
class
AboutPurchaseCourseTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
AboutPurchaseCourseTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
This test class runs through a suite of verifications regarding
This test class runs through a suite of verifications regarding
purchaseable courses
purchaseable courses
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
AboutPurchaseCourseTestCase
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
org
=
'MITx'
,
number
=
'buyme'
,
display_name
=
'Course To Buy'
)
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
tomorrow
=
now
+
datetime
.
timedelta
(
days
=
1
)
nextday
=
tomorrow
+
datetime
.
timedelta
(
days
=
1
)
cls
.
closed_course
=
CourseFactory
.
create
(
org
=
'MITx'
,
number
=
'closed'
,
display_name
=
'Closed Course To Buy'
,
enrollment_start
=
tomorrow
,
enrollment_end
=
nextday
)
def
setUp
(
self
):
def
setUp
(
self
):
super
(
AboutPurchaseCourseTestCase
,
self
)
.
setUp
()
super
(
AboutPurchaseCourseTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
org
=
'MITx'
,
number
=
'buyme'
,
display_name
=
'Course To Buy'
)
self
.
_set_ecomm
(
self
.
course
)
self
.
_set_ecomm
(
self
.
course
)
self
.
_set_ecomm
(
self
.
closed_course
)
def
_set_ecomm
(
self
,
course
):
def
_set_ecomm
(
self
,
course
):
"""
"""
...
@@ -487,19 +516,12 @@ class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
...
@@ -487,19 +516,12 @@ class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
window
window
"""
"""
self
.
setup_user
()
self
.
setup_user
()
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
tomorrow
=
now
+
datetime
.
timedelta
(
days
=
1
)
nextday
=
tomorrow
+
datetime
.
timedelta
(
days
=
1
)
self
.
course
.
enrollment_start
=
tomorrow
self
.
course
.
enrollment_end
=
nextday
self
.
course
=
self
.
update_course
(
self
.
course
,
self
.
user
.
id
)
url
=
reverse
(
'about_course'
,
args
=
[
self
.
course
.
id
.
to_deprecated_string
()])
url
=
reverse
(
'about_course'
,
args
=
[
self
.
c
losed_c
ourse
.
id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
)
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"Enrollment is Closed"
,
resp
.
content
)
self
.
assertIn
(
"Enrollment is Closed"
,
resp
.
content
)
self
.
assertNotIn
(
"Add
buyme
to Cart <span>($10 USD)</span>"
,
resp
.
content
)
self
.
assertNotIn
(
"Add
closed
to Cart <span>($10 USD)</span>"
,
resp
.
content
)
# course price is visible ihe course_about page when the course
# course price is visible ihe course_about page when the course
# mode is set to honor and it's price is set
# mode is set to honor and it's price is set
...
...
lms/djangoapps/courseware/tests/test_course_info.py
View file @
ad9498ec
...
@@ -30,18 +30,22 @@ from lms.djangoapps.ccx.tests.factories import CcxFactory
...
@@ -30,18 +30,22 @@ from lms.djangoapps.ccx.tests.factories import CcxFactory
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
CourseInfoTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
CourseInfoTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
Tests for the Course Info page
Tests for the Course Info page
"""
"""
def
setUp
(
self
):
@classmethod
super
(
CourseInfoTestCase
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
self
.
course
=
CourseFactory
.
create
()
super
(
CourseInfoTestCase
,
cls
)
.
setUpClass
()
self
.
page
=
ItemFactory
.
create
(
cls
.
course
=
CourseFactory
.
create
()
category
=
"course_info"
,
parent_location
=
self
.
course
.
location
,
cls
.
page
=
ItemFactory
.
create
(
category
=
"course_info"
,
parent_location
=
cls
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"updates"
data
=
"OOGIE BLOOGIE"
,
display_name
=
"updates"
)
)
def
setUp
(
self
):
super
(
CourseInfoTestCase
,
self
)
.
setUp
()
def
test_logged_in_unenrolled
(
self
):
def
test_logged_in_unenrolled
(
self
):
self
.
setup_user
()
self
.
setup_user
()
url
=
reverse
(
'info'
,
args
=
[
self
.
course
.
id
.
to_deprecated_string
()])
url
=
reverse
(
'info'
,
args
=
[
self
.
course
.
id
.
to_deprecated_string
()])
...
@@ -203,11 +207,15 @@ class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTest
...
@@ -203,11 +207,15 @@ class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTest
Tests for the info page of self-paced courses.
Tests for the info page of self-paced courses.
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
SelfPacedCourseInfoTestCase
,
cls
)
.
setUpClass
()
cls
.
instructor_paced_course
=
CourseFactory
.
create
(
self_paced
=
False
)
cls
.
self_paced_course
=
CourseFactory
.
create
(
self_paced
=
True
)
def
setUp
(
self
):
def
setUp
(
self
):
SelfPacedConfiguration
(
enabled
=
True
)
.
save
()
SelfPacedConfiguration
(
enabled
=
True
)
.
save
()
super
(
SelfPacedCourseInfoTestCase
,
self
)
.
setUp
()
super
(
SelfPacedCourseInfoTestCase
,
self
)
.
setUp
()
self
.
instructor_paced_course
=
CourseFactory
.
create
(
self_paced
=
False
)
self
.
self_paced_course
=
CourseFactory
.
create
(
self_paced
=
True
)
self
.
setup_user
()
self
.
setup_user
()
def
fetch_course_info_with_queries
(
self
,
course
,
sql_queries
,
mongo_queries
):
def
fetch_course_info_with_queries
(
self
,
course
,
sql_queries
,
mongo_queries
):
...
...
lms/djangoapps/courseware/tests/test_course_survey.py
View file @
ad9498ec
...
@@ -13,27 +13,42 @@ from survey.models import SurveyForm, SurveyAnswer
...
@@ -13,27 +13,42 @@ from survey.models import SurveyForm, SurveyAnswer
from
common.test.utils
import
XssTestMixin
from
common.test.utils
import
XssTestMixin
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
SurveyViewsTests
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
,
XssTestMixin
):
class
SurveyViewsTests
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
,
XssTestMixin
):
"""
"""
All tests for the views.py file
All tests for the views.py file
"""
"""
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
)]
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
)]
@classmethod
def
setUpClass
(
cls
):
super
(
SurveyViewsTests
,
cls
)
.
setUpClass
()
cls
.
test_survey_name
=
'TestSurvey'
cls
.
course
=
CourseFactory
.
create
(
display_name
=
'<script>alert("XSS")</script>'
,
course_survey_required
=
True
,
course_survey_name
=
cls
.
test_survey_name
)
cls
.
course_with_bogus_survey
=
CourseFactory
.
create
(
course_survey_required
=
True
,
course_survey_name
=
"DoesNotExist"
)
cls
.
course_without_survey
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
"""
"""
Set up the test data used in the specific tests
Set up the test data used in the specific tests
"""
"""
super
(
SurveyViewsTests
,
self
)
.
setUp
()
super
(
SurveyViewsTests
,
self
)
.
setUp
()
self
.
test_survey_name
=
'TestSurvey'
self
.
test_form
=
'<input name="field1"></input>'
self
.
test_form
=
'<input name="field1"></input>'
self
.
survey
=
SurveyForm
.
create
(
self
.
test_survey_name
,
self
.
test_form
)
self
.
survey
=
SurveyForm
.
create
(
self
.
test_survey_name
,
self
.
test_form
)
self
.
student_answers
=
OrderedDict
({
self
.
student_answers
=
OrderedDict
({
...
@@ -41,19 +56,6 @@ class SurveyViewsTests(LoginEnrollmentTestCase, ModuleStoreTestCase, XssTestMixi
...
@@ -41,19 +56,6 @@ class SurveyViewsTests(LoginEnrollmentTestCase, ModuleStoreTestCase, XssTestMixi
u'field2'
:
u'value2'
,
u'field2'
:
u'value2'
,
})
})
self
.
course
=
CourseFactory
.
create
(
display_name
=
'<script>alert("XSS")</script>'
,
course_survey_required
=
True
,
course_survey_name
=
self
.
test_survey_name
)
self
.
course_with_bogus_survey
=
CourseFactory
.
create
(
course_survey_required
=
True
,
course_survey_name
=
"DoesNotExist"
)
self
.
course_without_survey
=
CourseFactory
.
create
()
# Create student accounts and activate them.
# Create student accounts and activate them.
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
email
,
password
=
self
.
STUDENT_INFO
[
i
]
email
,
password
=
self
.
STUDENT_INFO
[
i
]
...
...
lms/djangoapps/courseware/tests/test_credit_requirements.py
View file @
ad9498ec
...
@@ -11,7 +11,7 @@ from pytz import UTC
...
@@ -11,7 +11,7 @@ from pytz import UTC
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
util.date_utils
import
get_time_display
,
DEFAULT_SHORT_DATE_FORMAT
from
util.date_utils
import
get_time_display
,
DEFAULT_SHORT_DATE_FORMAT
...
@@ -23,7 +23,7 @@ from openedx.core.djangoapps.credit.models import CreditCourse
...
@@ -23,7 +23,7 @@ from openedx.core.djangoapps.credit.models import CreditCourse
@patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_CREDIT_ELIGIBILITY"
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_CREDIT_ELIGIBILITY"
:
True
})
@ddt.ddt
@ddt.ddt
class
ProgressPageCreditRequirementsTest
(
ModuleStoreTestCase
):
class
ProgressPageCreditRequirementsTest
(
Shared
ModuleStoreTestCase
):
"""
"""
Tests for credit requirement display on the progress page.
Tests for credit requirement display on the progress page.
"""
"""
...
@@ -35,11 +35,15 @@ class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
...
@@ -35,11 +35,15 @@ class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
MIN_GRADE_REQ_DISPLAY
=
"Final Grade Credit Requirement"
MIN_GRADE_REQ_DISPLAY
=
"Final Grade Credit Requirement"
VERIFICATION_REQ_DISPLAY
=
"Midterm Exam Credit Requirement"
VERIFICATION_REQ_DISPLAY
=
"Midterm Exam Credit Requirement"
@classmethod
def
setUpClass
(
cls
):
super
(
ProgressPageCreditRequirementsTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
super
(
ProgressPageCreditRequirementsTest
,
self
)
.
setUp
()
super
(
ProgressPageCreditRequirementsTest
,
self
)
.
setUp
()
# Create a course and configure it as a credit course
# Configure course as a credit course
self
.
course
=
CourseFactory
.
create
()
CreditCourse
.
objects
.
create
(
course_key
=
self
.
course
.
id
,
enabled
=
True
)
CreditCourse
.
objects
.
create
(
course_key
=
self
.
course
.
id
,
enabled
=
True
)
# Configure credit requirements (passing grade and in-course reverification)
# Configure credit requirements (passing grade and in-course reverification)
...
...
lms/djangoapps/courseware/tests/test_field_overrides.py
View file @
ad9498ec
...
@@ -9,7 +9,7 @@ from xblock.field_data import DictFieldData
...
@@ -9,7 +9,7 @@ from xblock.field_data import DictFieldData
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
(
from
xmodule.modulestore.tests.django_utils
import
(
ModuleStoreTestCase
,
ModuleStoreTestCase
,
)
SharedModuleStoreTestCase
)
from
..field_overrides
import
(
from
..field_overrides
import
(
disable_overrides
,
disable_overrides
,
...
...
lms/djangoapps/courseware/tests/test_grades.py
View file @
ad9498ec
...
@@ -28,7 +28,7 @@ from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
...
@@ -28,7 +28,7 @@ from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
def
_grade_with_errors
(
student
,
request
,
course
,
keep_raw_scores
=
False
):
def
_grade_with_errors
(
student
,
request
,
course
,
keep_raw_scores
=
False
):
...
@@ -46,23 +46,27 @@ def _grade_with_errors(student, request, course, keep_raw_scores=False):
...
@@ -46,23 +46,27 @@ def _grade_with_errors(student, request, course, keep_raw_scores=False):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestGradeIteration
(
ModuleStoreTestCase
):
class
TestGradeIteration
(
Shared
ModuleStoreTestCase
):
"""
"""
Test iteration through student gradesets.
Test iteration through student gradesets.
"""
"""
COURSE_NUM
=
"1000"
COURSE_NUM
=
"1000"
COURSE_NAME
=
"grading_test_course"
COURSE_NAME
=
"grading_test_course"
@classmethod
def
setUpClass
(
cls
):
super
(
TestGradeIteration
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
display_name
=
cls
.
COURSE_NAME
,
number
=
cls
.
COURSE_NUM
)
def
setUp
(
self
):
def
setUp
(
self
):
"""
"""
Create a course and a handful of users to assign grades
Create a course and a handful of users to assign grades
"""
"""
super
(
TestGradeIteration
,
self
)
.
setUp
()
super
(
TestGradeIteration
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
display_name
=
self
.
COURSE_NAME
,
number
=
self
.
COURSE_NUM
)
self
.
students
=
[
self
.
students
=
[
UserFactory
.
create
(
username
=
'student1'
),
UserFactory
.
create
(
username
=
'student1'
),
UserFactory
.
create
(
username
=
'student2'
),
UserFactory
.
create
(
username
=
'student2'
),
...
@@ -142,19 +146,24 @@ class TestGradeIteration(ModuleStoreTestCase):
...
@@ -142,19 +146,24 @@ class TestGradeIteration(ModuleStoreTestCase):
return
students_to_gradesets
,
students_to_errors
return
students_to_gradesets
,
students_to_errors
class
TestMaxScoresCache
(
ModuleStoreTestCase
):
class
TestMaxScoresCache
(
Shared
ModuleStoreTestCase
):
"""
"""
Tests for the MaxScoresCache
Tests for the MaxScoresCache
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestMaxScoresCache
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
cls
.
problems
=
[]
for
_
in
xrange
(
3
):
cls
.
problems
.
append
(
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
cls
.
course
)
)
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestMaxScoresCache
,
self
)
.
setUp
()
super
(
TestMaxScoresCache
,
self
)
.
setUp
()
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
self
.
course
=
CourseFactory
.
create
()
self
.
problems
=
[]
for
_
in
xrange
(
3
):
self
.
problems
.
append
(
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
self
.
course
)
)
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
)
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
)
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
...
@@ -183,16 +192,16 @@ class TestMaxScoresCache(ModuleStoreTestCase):
...
@@ -183,16 +192,16 @@ class TestMaxScoresCache(ModuleStoreTestCase):
self
.
assertEqual
(
max_scores_cache
.
num_cached_from_remote
(),
1
)
self
.
assertEqual
(
max_scores_cache
.
num_cached_from_remote
(),
1
)
class
TestFieldDataCacheScorableLocations
(
ModuleStoreTestCase
):
class
TestFieldDataCacheScorableLocations
(
Shared
ModuleStoreTestCase
):
"""
"""
Make sure we can filter the locations we pull back student state for via
Make sure we can filter the locations we pull back student state for via
the FieldDataCache.
the FieldDataCache.
"""
"""
def
setUp
(
self
):
@classmethod
super
(
TestFieldDataCacheScorableLocations
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
s
elf
.
student
=
UserFactory
.
create
()
s
uper
(
TestFieldDataCacheScorableLocations
,
cls
)
.
setUpClass
()
self
.
course
=
CourseFactory
.
create
()
cls
.
course
=
CourseFactory
.
create
()
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent
=
self
.
course
)
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent
=
cls
.
course
)
sequential
=
ItemFactory
.
create
(
category
=
'sequential'
,
parent
=
chapter
)
sequential
=
ItemFactory
.
create
(
category
=
'sequential'
,
parent
=
chapter
)
vertical
=
ItemFactory
.
create
(
category
=
'vertical'
,
parent
=
sequential
)
vertical
=
ItemFactory
.
create
(
category
=
'vertical'
,
parent
=
sequential
)
ItemFactory
.
create
(
category
=
'video'
,
parent
=
vertical
)
ItemFactory
.
create
(
category
=
'video'
,
parent
=
vertical
)
...
@@ -200,6 +209,10 @@ class TestFieldDataCacheScorableLocations(ModuleStoreTestCase):
...
@@ -200,6 +209,10 @@ class TestFieldDataCacheScorableLocations(ModuleStoreTestCase):
ItemFactory
.
create
(
category
=
'discussion'
,
parent
=
vertical
)
ItemFactory
.
create
(
category
=
'discussion'
,
parent
=
vertical
)
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
vertical
)
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
vertical
)
def
setUp
(
self
):
super
(
TestFieldDataCacheScorableLocations
,
self
)
.
setUp
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
)
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
)
def
test_field_data_cache_scorable_locations
(
self
):
def
test_field_data_cache_scorable_locations
(
self
):
...
@@ -334,45 +347,43 @@ class TestProgressSummary(TestCase):
...
@@ -334,45 +347,43 @@ class TestProgressSummary(TestCase):
self
.
assertEqual
(
possible
,
0
)
self
.
assertEqual
(
possible
,
0
)
class
TestGetModuleScore
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
TestGetModuleScore
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
Test get_module_score
Test get_module_score
"""
"""
def
setUp
(
self
):
@classmethod
"""
def
setUpClass
(
cls
):
Set up test course
super
(
TestGetModuleScore
,
cls
)
.
setUpClass
()
"""
cls
.
course
=
CourseFactory
.
create
()
super
(
TestGetModuleScore
,
self
)
.
setUp
()
cls
.
chapter
=
ItemFactory
.
create
(
self
.
course
=
CourseFactory
.
create
()
parent
=
cls
.
course
,
self
.
chapter
=
ItemFactory
.
create
(
parent
=
self
.
course
,
category
=
"chapter"
,
category
=
"chapter"
,
display_name
=
"Test Chapter"
display_name
=
"Test Chapter"
)
)
self
.
seq1
=
ItemFactory
.
create
(
cls
.
seq1
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
parent
=
cls
.
chapter
,
category
=
'sequential'
,
category
=
'sequential'
,
display_name
=
"Test Sequential"
,
display_name
=
"Test Sequential"
,
graded
=
True
graded
=
True
)
)
self
.
seq2
=
ItemFactory
.
create
(
cls
.
seq2
=
ItemFactory
.
create
(
parent
=
self
.
chapter
,
parent
=
cls
.
chapter
,
category
=
'sequential'
,
category
=
'sequential'
,
display_name
=
"Test Sequential"
,
display_name
=
"Test Sequential"
,
graded
=
True
graded
=
True
)
)
self
.
vert1
=
ItemFactory
.
create
(
cls
.
vert1
=
ItemFactory
.
create
(
parent
=
self
.
seq1
,
parent
=
cls
.
seq1
,
category
=
'vertical'
,
category
=
'vertical'
,
display_name
=
'Test Vertical 1'
display_name
=
'Test Vertical 1'
)
)
self
.
vert2
=
ItemFactory
.
create
(
cls
.
vert2
=
ItemFactory
.
create
(
parent
=
self
.
seq2
,
parent
=
cls
.
seq2
,
category
=
'vertical'
,
category
=
'vertical'
,
display_name
=
'Test Vertical 2'
display_name
=
'Test Vertical 2'
)
)
self
.
randomize
=
ItemFactory
.
create
(
cls
.
randomize
=
ItemFactory
.
create
(
parent
=
self
.
vert2
,
parent
=
cls
.
vert2
,
category
=
'randomize'
,
category
=
'randomize'
,
display_name
=
'Test Randomize'
display_name
=
'Test Randomize'
)
)
...
@@ -381,31 +392,37 @@ class TestGetModuleScore(LoginEnrollmentTestCase, ModuleStoreTestCase):
...
@@ -381,31 +392,37 @@ class TestGetModuleScore(LoginEnrollmentTestCase, ModuleStoreTestCase):
choices
=
[
False
,
False
,
True
,
False
],
choices
=
[
False
,
False
,
True
,
False
],
choice_names
=
[
'choice_0'
,
'choice_1'
,
'choice_2'
,
'choice_3'
]
choice_names
=
[
'choice_0'
,
'choice_1'
,
'choice_2'
,
'choice_3'
]
)
)
self
.
problem1
=
ItemFactory
.
create
(
cls
.
problem1
=
ItemFactory
.
create
(
parent
=
self
.
vert1
,
parent
=
cls
.
vert1
,
category
=
"problem"
,
category
=
"problem"
,
display_name
=
"Test Problem 1"
,
display_name
=
"Test Problem 1"
,
data
=
problem_xml
data
=
problem_xml
)
)
self
.
problem2
=
ItemFactory
.
create
(
cls
.
problem2
=
ItemFactory
.
create
(
parent
=
self
.
vert1
,
parent
=
cls
.
vert1
,
category
=
"problem"
,
category
=
"problem"
,
display_name
=
"Test Problem 2"
,
display_name
=
"Test Problem 2"
,
data
=
problem_xml
data
=
problem_xml
)
)
self
.
problem3
=
ItemFactory
.
create
(
cls
.
problem3
=
ItemFactory
.
create
(
parent
=
self
.
randomize
,
parent
=
cls
.
randomize
,
category
=
"problem"
,
category
=
"problem"
,
display_name
=
"Test Problem 3"
,
display_name
=
"Test Problem 3"
,
data
=
problem_xml
data
=
problem_xml
)
)
self
.
problem4
=
ItemFactory
.
create
(
cls
.
problem4
=
ItemFactory
.
create
(
parent
=
self
.
randomize
,
parent
=
cls
.
randomize
,
category
=
"problem"
,
category
=
"problem"
,
display_name
=
"Test Problem 4"
,
display_name
=
"Test Problem 4"
,
data
=
problem_xml
data
=
problem_xml
)
)
def
setUp
(
self
):
"""
Set up test course
"""
super
(
TestGetModuleScore
,
self
)
.
setUp
()
self
.
request
=
get_request_for_user
(
UserFactory
())
self
.
request
=
get_request_for_user
(
UserFactory
())
self
.
client
.
login
(
username
=
self
.
request
.
user
.
username
,
password
=
"test"
)
self
.
client
.
login
(
username
=
self
.
request
.
user
.
username
,
password
=
"test"
)
CourseEnrollment
.
enroll
(
self
.
request
.
user
,
self
.
course
.
id
)
CourseEnrollment
.
enroll
(
self
.
request
.
user
,
self
.
course
.
id
)
...
...
lms/djangoapps/courseware/tests/test_lti_integration.py
View file @
ad9498ec
...
@@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse
...
@@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse
from
courseware.tests
import
BaseTestXmodule
from
courseware.tests
import
BaseTestXmodule
from
courseware.views
import
get_course_lti_endpoints
from
courseware.views
import
get_course_lti_endpoints
from
lms.djangoapps.lms_xblock.runtime
import
quote_slashes
from
lms.djangoapps.lms_xblock.runtime
import
quote_slashes
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.x_module
import
STUDENT_VIEW
from
xmodule.x_module
import
STUDENT_VIEW
...
@@ -125,7 +125,7 @@ class TestLTI(BaseTestXmodule):
...
@@ -125,7 +125,7 @@ class TestLTI(BaseTestXmodule):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestLTIModuleListing
(
ModuleStoreTestCase
):
class
TestLTIModuleListing
(
Shared
ModuleStoreTestCase
):
"""
"""
a test for the rest endpoint that lists LTI modules in a course
a test for the rest endpoint that lists LTI modules in a course
"""
"""
...
@@ -133,42 +133,46 @@ class TestLTIModuleListing(ModuleStoreTestCase):
...
@@ -133,42 +133,46 @@ class TestLTIModuleListing(ModuleStoreTestCase):
COURSE_SLUG
=
"100"
COURSE_SLUG
=
"100"
COURSE_NAME
=
"test_course"
COURSE_NAME
=
"test_course"
def
setUp
(
self
):
@classmethod
"""Create course, 2 chapters, 2 sections"""
def
setUpClass
(
cls
):
super
(
TestLTIModuleListing
,
self
)
.
setUp
()
super
(
TestLTIModuleListing
,
cls
)
.
setUpClass
()
self
.
course
=
CourseFactory
.
create
(
display_name
=
self
.
COURSE_NAME
,
number
=
self
.
COURSE_SLUG
)
cls
.
course
=
CourseFactory
.
create
(
display_name
=
cls
.
COURSE_NAME
,
number
=
cls
.
COURSE_SLUG
)
self
.
chapter1
=
ItemFactory
.
create
(
cls
.
chapter1
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
display_name
=
"chapter1"
,
display_name
=
"chapter1"
,
category
=
'chapter'
)
category
=
'chapter'
)
self
.
section1
=
ItemFactory
.
create
(
cls
.
section1
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter1
.
location
,
parent_location
=
cls
.
chapter1
.
location
,
display_name
=
"section1"
,
display_name
=
"section1"
,
category
=
'sequential'
)
category
=
'sequential'
)
self
.
chapter2
=
ItemFactory
.
create
(
cls
.
chapter2
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
display_name
=
"chapter2"
,
display_name
=
"chapter2"
,
category
=
'chapter'
)
category
=
'chapter'
)
self
.
section2
=
ItemFactory
.
create
(
cls
.
section2
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter2
.
location
,
parent_location
=
cls
.
chapter2
.
location
,
display_name
=
"section2"
,
display_name
=
"section2"
,
category
=
'sequential'
)
category
=
'sequential'
)
# creates one draft and one published lti module, in different sections
# creates one draft and one published lti module, in different sections
self
.
lti_published
=
ItemFactory
.
create
(
cls
.
lti_published
=
ItemFactory
.
create
(
parent_location
=
self
.
section1
.
location
,
parent_location
=
cls
.
section1
.
location
,
display_name
=
"lti published"
,
display_name
=
"lti published"
,
category
=
"lti"
,
category
=
"lti"
,
location
=
self
.
course
.
id
.
make_usage_key
(
'lti'
,
'lti_published'
),
location
=
cls
.
course
.
id
.
make_usage_key
(
'lti'
,
'lti_published'
),
)
)
self
.
lti_draft
=
ItemFactory
.
create
(
cls
.
lti_draft
=
ItemFactory
.
create
(
parent_location
=
self
.
section2
.
location
,
parent_location
=
cls
.
section2
.
location
,
display_name
=
"lti draft"
,
display_name
=
"lti draft"
,
category
=
"lti"
,
category
=
"lti"
,
location
=
self
.
course
.
id
.
make_usage_key
(
'lti'
,
'lti_draft'
),
location
=
cls
.
course
.
id
.
make_usage_key
(
'lti'
,
'lti_draft'
),
publish_item
=
False
,
publish_item
=
False
,
)
)
def
setUp
(
self
):
"""Create course, 2 chapters, 2 sections"""
super
(
TestLTIModuleListing
,
self
)
.
setUp
()
def
expected_handler_url
(
self
,
handler
):
def
expected_handler_url
(
self
,
handler
):
"""convenience method to get the reversed handler urls"""
"""convenience method to get the reversed handler urls"""
return
"https://{}{}"
.
format
(
settings
.
SITE_NAME
,
reverse
(
return
"https://{}{}"
.
format
(
settings
.
SITE_NAME
,
reverse
(
...
...
lms/djangoapps/courseware/tests/test_masquerade.py
View file @
ad9498ec
...
@@ -25,40 +25,36 @@ from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
...
@@ -25,40 +25,36 @@ from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
xblock.runtime
import
DictKeyValueStore
from
xblock.runtime
import
DictKeyValueStore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
xmodule.partitions.partitions
import
Group
,
UserPartition
class
MasqueradeTestCase
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
MasqueradeTestCase
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Base class for masquerade tests that sets up a test course and enrolls a user in the course.
Base class for masquerade tests that sets up a test course and enrolls a user in the course.
"""
"""
def
setUp
(
self
):
@classmethod
super
(
MasqueradeTestCase
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
super
(
MasqueradeTestCase
,
cls
)
.
setUpClass
()
# By default, tests run with DISABLE_START_DATES=True. To test that masquerading as a student is
cls
.
course
=
CourseFactory
.
create
(
number
=
'masquerade-test'
,
metadata
=
{
'start'
:
datetime
.
now
(
UTC
())})
# working properly, we must use start dates and set a start date in the past (otherwise the access
cls
.
info_page
=
ItemFactory
.
create
(
# checks exist prematurely).
category
=
"course_info"
,
parent_location
=
cls
.
course
.
location
,
self
.
course
=
CourseFactory
.
create
(
number
=
'masquerade-test'
,
metadata
=
{
'start'
:
datetime
.
now
(
UTC
())})
# Creates info page and puts random data in it for specific student info page test
self
.
info_page
=
ItemFactory
.
create
(
category
=
"course_info"
,
parent_location
=
self
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"updates"
data
=
"OOGIE BLOOGIE"
,
display_name
=
"updates"
)
)
self
.
chapter
=
ItemFactory
.
create
(
cls
.
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
category
=
"chapter"
,
category
=
"chapter"
,
display_name
=
"Test Section"
,
display_name
=
"Test Section"
,
)
)
self
.
sequential_display_name
=
"Test Masquerade Subsection"
cls
.
sequential_display_name
=
"Test Masquerade Subsection"
self
.
sequential
=
ItemFactory
.
create
(
cls
.
sequential
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter
.
location
,
parent_location
=
cls
.
chapter
.
location
,
category
=
"sequential"
,
category
=
"sequential"
,
display_name
=
self
.
sequential_display_name
,
display_name
=
cls
.
sequential_display_name
,
)
)
self
.
vertical
=
ItemFactory
.
create
(
cls
.
vertical
=
ItemFactory
.
create
(
parent_location
=
self
.
sequential
.
location
,
parent_location
=
cls
.
sequential
.
location
,
category
=
"vertical"
,
category
=
"vertical"
,
display_name
=
"Test Unit"
,
display_name
=
"Test Unit"
,
)
)
...
@@ -69,13 +65,17 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -69,13 +65,17 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
options
=
[
'Correct'
,
'Incorrect'
],
options
=
[
'Correct'
,
'Incorrect'
],
correct_option
=
'Correct'
correct_option
=
'Correct'
)
)
self
.
problem_display_name
=
"TestMasqueradeProblem"
cls
.
problem_display_name
=
"TestMasqueradeProblem"
self
.
problem
=
ItemFactory
.
create
(
cls
.
problem
=
ItemFactory
.
create
(
parent_location
=
self
.
vertical
.
location
,
parent_location
=
cls
.
vertical
.
location
,
category
=
'problem'
,
category
=
'problem'
,
data
=
problem_xml
,
data
=
problem_xml
,
display_name
=
self
.
problem_display_name
display_name
=
cls
.
problem_display_name
)
)
def
setUp
(
self
):
super
(
MasqueradeTestCase
,
self
)
.
setUp
()
self
.
test_user
=
self
.
create_user
()
self
.
test_user
=
self
.
create_user
()
self
.
login
(
self
.
test_user
.
email
,
'test'
)
self
.
login
(
self
.
test_user
.
email
,
'test'
)
self
.
enroll
(
self
.
course
,
True
)
self
.
enroll
(
self
.
course
,
True
)
...
...
lms/djangoapps/courseware/tests/test_microsites.py
View file @
ad9498ec
...
@@ -11,51 +11,42 @@ from course_modes.models import CourseMode
...
@@ -11,51 +11,42 @@ from course_modes.models import CourseMode
from
xmodule.course_module
import
(
from
xmodule.course_module
import
(
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
CATALOG_VISIBILITY_NONE
)
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
CATALOG_VISIBILITY_NONE
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestMicrosites
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestMicrosites
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
This is testing of the Microsite feature
This is testing of the Microsite feature
"""
"""
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
),
(
'view2@test.com'
,
'foo'
)]
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
),
(
'view2@test.com'
,
'foo'
)]
def
setUp
(
self
):
@classmethod
super
(
TestMicrosites
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
super
(
TestMicrosites
,
cls
)
.
setUpClass
()
# use a different hostname to test Microsites since they are
cls
.
course
=
CourseFactory
.
create
(
# triggered on subdomain mappings
#
# NOTE: The Microsite Configuration is in lms/envs/test.py. The content for the Test Microsite is in
# test_microsites/test_microsite.
#
# IMPORTANT: For these tests to work, this domain must be defined via
# DNS configuration (either local or published)
self
.
course
=
CourseFactory
.
create
(
display_name
=
'Robot_Super_Course'
,
display_name
=
'Robot_Super_Course'
,
org
=
'TestMicrositeX'
,
org
=
'TestMicrositeX'
,
emit_signals
=
True
,
emit_signals
=
True
,
)
)
self
.
chapter0
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
cls
.
chapter0
=
ItemFactory
.
create
(
parent_location
=
cls
.
course
.
location
,
display_name
=
'Overview'
)
display_name
=
'Overview'
)
self
.
chapter9
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
cls
.
chapter9
=
ItemFactory
.
create
(
parent_location
=
cls
.
course
.
location
,
display_name
=
'factory_chapter'
)
display_name
=
'factory_chapter'
)
self
.
section0
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter0
.
location
,
cls
.
section0
=
ItemFactory
.
create
(
parent_location
=
cls
.
chapter0
.
location
,
display_name
=
'Welcome'
)
display_name
=
'Welcome'
)
self
.
section9
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter9
.
location
,
cls
.
section9
=
ItemFactory
.
create
(
parent_location
=
cls
.
chapter9
.
location
,
display_name
=
'factory_section'
)
display_name
=
'factory_section'
)
self
.
course_outside_microsite
=
CourseFactory
.
create
(
cls
.
course_outside_microsite
=
CourseFactory
.
create
(
display_name
=
'Robot_Course_Outside_Microsite'
,
display_name
=
'Robot_Course_Outside_Microsite'
,
org
=
'FooX'
,
org
=
'FooX'
,
emit_signals
=
True
,
emit_signals
=
True
,
)
)
# have a course which explicitly sets visibility in catalog to False
# have a course which explicitly sets visibility in catalog to False
self
.
course_hidden_visibility
=
CourseFactory
.
create
(
cls
.
course_hidden_visibility
=
CourseFactory
.
create
(
display_name
=
'Hidden_course'
,
display_name
=
'Hidden_course'
,
org
=
'TestMicrositeX'
,
org
=
'TestMicrositeX'
,
catalog_visibility
=
CATALOG_VISIBILITY_NONE
,
catalog_visibility
=
CATALOG_VISIBILITY_NONE
,
...
@@ -63,7 +54,7 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -63,7 +54,7 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
)
# have a course which explicitly sets visibility in catalog and about to true
# have a course which explicitly sets visibility in catalog and about to true
self
.
course_with_visibility
=
CourseFactory
.
create
(
cls
.
course_with_visibility
=
CourseFactory
.
create
(
display_name
=
'visible_course'
,
display_name
=
'visible_course'
,
org
=
'TestMicrositeX'
,
org
=
'TestMicrositeX'
,
course
=
"foo"
,
course
=
"foo"
,
...
@@ -71,6 +62,9 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -71,6 +62,9 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
emit_signals
=
True
,
emit_signals
=
True
,
)
)
def
setUp
(
self
):
super
(
TestMicrosites
,
self
)
.
setUp
()
def
setup_users
(
self
):
def
setup_users
(
self
):
# Create student accounts and activate them.
# Create student accounts and activate them.
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
...
...
lms/djangoapps/courseware/tests/test_middleware.py
View file @
ad9498ec
...
@@ -10,19 +10,22 @@ from nose.plugins.attrib import attr
...
@@ -10,19 +10,22 @@ from nose.plugins.attrib import attr
import
courseware.courses
as
courses
import
courseware.courses
as
courses
from
courseware.middleware
import
RedirectUnenrolledMiddleware
from
courseware.middleware
import
RedirectUnenrolledMiddleware
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
CoursewareMiddlewareTestCase
(
ModuleStoreTestCase
):
class
CoursewareMiddlewareTestCase
(
Shared
ModuleStoreTestCase
):
"""Tests that courseware middleware is correctly redirected"""
"""Tests that courseware middleware is correctly redirected"""
@classmethod
def
setUpClass
(
cls
):
super
(
CoursewareMiddlewareTestCase
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
super
(
CoursewareMiddlewareTestCase
,
self
)
.
setUp
()
super
(
CoursewareMiddlewareTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
def
check_user_not_enrolled_redirect
(
self
):
def
check_user_not_enrolled_redirect
(
self
):
"""A UserNotEnrolled exception should trigger a redirect"""
"""A UserNotEnrolled exception should trigger a redirect"""
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
ad9498ec
...
@@ -45,7 +45,7 @@ from student.models import anonymous_id_for_user
...
@@ -45,7 +45,7 @@ from student.models import anonymous_id_for_user
from
xmodule.modulestore.tests.django_utils
import
(
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_XML_MODULESTORE
,
TEST_DATA_XML_MODULESTORE
,
)
SharedModuleStoreTestCase
)
from
xmodule.lti_module
import
LTIDescriptor
from
xmodule.lti_module
import
LTIDescriptor
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
...
@@ -121,10 +121,17 @@ class GradedStatelessXBlock(XBlock):
...
@@ -121,10 +121,17 @@ class GradedStatelessXBlock(XBlock):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
@ddt.ddt
class
ModuleRenderTestCase
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
ModuleRenderTestCase
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Tests of courseware.module_render
Tests of courseware.module_render
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
ModuleRenderTestCase
,
cls
)
.
setUpClass
()
cls
.
course_key
=
ToyCourseFactory
.
create
()
.
id
cls
.
toy_course
=
modulestore
()
.
get_course
(
cls
.
course_key
)
# TODO: this test relies on the specific setup of the toy course.
# TODO: this test relies on the specific setup of the toy course.
# It should be rewritten to build the course it needs and then test that.
# It should be rewritten to build the course it needs and then test that.
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -133,8 +140,6 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -133,8 +140,6 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
"""
super
(
ModuleRenderTestCase
,
self
)
.
setUp
()
super
(
ModuleRenderTestCase
,
self
)
.
setUp
()
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
toy_course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
mock_user
=
UserFactory
()
self
.
mock_user
=
UserFactory
()
self
.
mock_user
.
id
=
1
self
.
mock_user
.
id
=
1
self
.
request_factory
=
RequestFactory
()
self
.
request_factory
=
RequestFactory
()
...
@@ -401,17 +406,20 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -401,17 +406,20 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestHandleXBlockCallback
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestHandleXBlockCallback
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Test the handle_xblock_callback function
Test the handle_xblock_callback function
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestHandleXBlockCallback
,
cls
)
.
setUpClass
()
cls
.
course_key
=
ToyCourseFactory
.
create
()
.
id
cls
.
toy_course
=
modulestore
()
.
get_course
(
cls
.
course_key
)
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestHandleXBlockCallback
,
self
)
.
setUp
()
super
(
TestHandleXBlockCallback
,
self
)
.
setUp
()
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
self
.
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
self
.
toy_course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
mock_user
=
UserFactory
.
create
()
self
.
mock_user
=
UserFactory
.
create
()
self
.
request_factory
=
RequestFactory
()
self
.
request_factory
=
RequestFactory
()
...
@@ -709,19 +717,24 @@ class TestTOC(ModuleStoreTestCase):
...
@@ -709,19 +717,24 @@ class TestTOC(ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
@ddt.ddt
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_SPECIAL_EXAMS'
:
True
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_SPECIAL_EXAMS'
:
True
})
class
TestProctoringRendering
(
ModuleStoreTestCase
):
class
TestProctoringRendering
(
SharedModuleStoreTestCase
):
@classmethod
def
setUpClass
(
cls
):
super
(
TestProctoringRendering
,
cls
)
.
setUpClass
()
cls
.
course_key
=
ToyCourseFactory
.
create
()
.
id
"""Check the Table of Contents for a course"""
"""Check the Table of Contents for a course"""
def
setUp
(
self
):
def
setUp
(
self
):
"""
"""
Set up the initial mongo datastores
Set up the initial mongo datastores
"""
"""
super
(
TestProctoringRendering
,
self
)
.
setUp
()
super
(
TestProctoringRendering
,
self
)
.
setUp
()
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
chapter
=
'Overview'
self
.
chapter
=
'Overview'
chapter_url
=
'
%
s/
%
s/
%
s'
%
(
'/courses'
,
self
.
course_key
,
self
.
chapter
)
chapter_url
=
'
%
s/
%
s/
%
s'
%
(
'/courses'
,
self
.
course_key
,
self
.
chapter
)
factory
=
RequestFactory
()
factory
=
RequestFactory
()
self
.
request
=
factory
.
get
(
chapter_url
)
self
.
request
=
factory
.
get
(
chapter_url
)
self
.
request
.
user
=
UserFactory
()
self
.
request
.
user
=
UserFactory
.
create
()
self
.
user
=
UserFactory
.
create
()
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_courselike
(
self
.
course_key
)
# pylint: disable=protected-access
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_courselike
(
self
.
course_key
)
# pylint: disable=protected-access
with
self
.
modulestore
.
bulk_operations
(
self
.
course_key
):
with
self
.
modulestore
.
bulk_operations
(
self
.
course_key
):
self
.
toy_course
=
self
.
store
.
get_course
(
self
.
course_key
,
depth
=
2
)
self
.
toy_course
=
self
.
store
.
get_course
(
self
.
course_key
,
depth
=
2
)
...
@@ -1028,7 +1041,15 @@ class TestProctoringRendering(ModuleStoreTestCase):
...
@@ -1028,7 +1041,15 @@ class TestProctoringRendering(ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestGatedSubsectionRendering
(
ModuleStoreTestCase
,
MilestonesTestCaseMixin
):
class
TestGatedSubsectionRendering
(
SharedModuleStoreTestCase
,
MilestonesTestCaseMixin
):
@classmethod
def
setUpClass
(
cls
):
super
(
TestGatedSubsectionRendering
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
cls
.
course
.
enable_subsection_gating
=
True
cls
.
course
.
save
()
cls
.
store
.
update_item
(
cls
.
course
,
0
)
"""
"""
Test the toc for a course is rendered correctly when there is gated content
Test the toc for a course is rendered correctly when there is gated content
"""
"""
...
@@ -1038,10 +1059,6 @@ class TestGatedSubsectionRendering(ModuleStoreTestCase, MilestonesTestCaseMixin)
...
@@ -1038,10 +1059,6 @@ class TestGatedSubsectionRendering(ModuleStoreTestCase, MilestonesTestCaseMixin)
"""
"""
super
(
TestGatedSubsectionRendering
,
self
)
.
setUp
()
super
(
TestGatedSubsectionRendering
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
course
.
enable_subsection_gating
=
True
self
.
course
.
save
()
self
.
store
.
update_item
(
self
.
course
,
0
)
self
.
chapter
=
ItemFactory
.
create
(
self
.
chapter
=
ItemFactory
.
create
(
parent
=
self
.
course
,
parent
=
self
.
course
,
category
=
"chapter"
,
category
=
"chapter"
,
...
@@ -1113,11 +1130,10 @@ class TestHtmlModifiers(ModuleStoreTestCase):
...
@@ -1113,11 +1130,10 @@ class TestHtmlModifiers(ModuleStoreTestCase):
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestHtmlModifiers
,
self
)
.
setUp
()
super
(
TestHtmlModifiers
,
self
)
.
setUp
()
self
.
user
=
User
Factory
.
create
()
self
.
course
=
Course
Factory
.
create
()
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
request
.
user
=
self
.
user
self
.
request
.
user
=
self
.
user
self
.
request
.
session
=
{}
self
.
request
.
session
=
{}
self
.
course
=
CourseFactory
.
create
()
self
.
content_string
=
'<p>This is the content<p>'
self
.
content_string
=
'<p>This is the content<p>'
self
.
rewrite_link
=
'<a href="/static/foo/content">Test rewrite</a>'
self
.
rewrite_link
=
'<a href="/static/foo/content">Test rewrite</a>'
self
.
rewrite_bad_link
=
'<img src="/static//file.jpg" />'
self
.
rewrite_bad_link
=
'<img src="/static//file.jpg" />'
...
@@ -1447,16 +1463,20 @@ class DetachedXBlock(XBlock):
...
@@ -1447,16 +1463,20 @@ class DetachedXBlock(XBlock):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISPLAY_DEBUG_INFO_TO_STAFF'
:
True
,
'DISPLAY_HISTOGRAMS_TO_STAFF'
:
True
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISPLAY_DEBUG_INFO_TO_STAFF'
:
True
,
'DISPLAY_HISTOGRAMS_TO_STAFF'
:
True
})
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
class
TestStaffDebugInfo
(
ModuleStoreTestCase
):
class
TestStaffDebugInfo
(
Shared
ModuleStoreTestCase
):
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
@classmethod
def
setUpClass
(
cls
):
super
(
TestStaffDebugInfo
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestStaffDebugInfo
,
self
)
.
setUp
()
super
(
TestStaffDebugInfo
,
self
)
.
setUp
()
self
.
user
=
UserFactory
.
create
()
self
.
user
=
UserFactory
.
create
()
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
request
.
user
=
self
.
user
self
.
request
.
user
=
self
.
user
self
.
request
.
session
=
{}
self
.
request
.
session
=
{}
self
.
course
=
CourseFactory
.
create
()
problem_xml
=
OptionResponseXMLFactory
()
.
build_xml
(
problem_xml
=
OptionResponseXMLFactory
()
.
build_xml
(
question_text
=
'The correct answer is Correct'
,
question_text
=
'The correct answer is Correct'
,
...
@@ -1589,16 +1609,20 @@ PER_STUDENT_ANONYMIZED_DESCRIPTORS = set(
...
@@ -1589,16 +1609,20 @@ PER_STUDENT_ANONYMIZED_DESCRIPTORS = set(
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
@ddt.ddt
class
TestAnonymousStudentId
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestAnonymousStudentId
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Test that anonymous_student_id is set correctly across a variety of XBlock types
Test that anonymous_student_id is set correctly across a variety of XBlock types
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestAnonymousStudentId
,
cls
)
.
setUpClass
()
cls
.
course_key
=
ToyCourseFactory
.
create
()
.
id
cls
.
course
=
modulestore
()
.
get_course
(
cls
.
course_key
)
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestAnonymousStudentId
,
self
)
.
setUp
(
create_user
=
False
)
super
(
TestAnonymousStudentId
,
self
)
.
setUp
()
self
.
user
=
UserFactory
()
self
.
user
=
UserFactory
()
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
def
_get_anonymous_id
(
self
,
course_id
,
xblock_class
):
def
_get_anonymous_id
(
self
,
course_id
,
xblock_class
):
...
@@ -1668,11 +1692,16 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -1668,11 +1692,16 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'track.views.tracker'
,
autospec
=
True
)
@patch
(
'track.views.tracker'
,
autospec
=
True
)
class
TestModuleTrackingContext
(
ModuleStoreTestCase
):
class
TestModuleTrackingContext
(
Shared
ModuleStoreTestCase
):
"""
"""
Ensure correct tracking information is included in events emitted during XBlock callback handling.
Ensure correct tracking information is included in events emitted during XBlock callback handling.
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestModuleTrackingContext
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestModuleTrackingContext
,
self
)
.
setUp
()
super
(
TestModuleTrackingContext
,
self
)
.
setUp
()
...
@@ -1926,10 +1955,16 @@ class TestEventPublishing(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -1926,10 +1955,16 @@ class TestEventPublishing(ModuleStoreTestCase, LoginEnrollmentTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
@ddt.ddt
class
LMSXBlockServiceBindingTest
(
ModuleStoreTestCase
):
class
LMSXBlockServiceBindingTest
(
Shared
ModuleStoreTestCase
):
"""
"""
Tests that the LMS Module System (XBlock Runtime) provides an expected set of services.
Tests that the LMS Module System (XBlock Runtime) provides an expected set of services.
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
LMSXBlockServiceBindingTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
"""
"""
Set up the user and other fields that will be used to instantiate the runtime.
Set up the user and other fields that will be used to instantiate the runtime.
...
@@ -1937,7 +1972,6 @@ class LMSXBlockServiceBindingTest(ModuleStoreTestCase):
...
@@ -1937,7 +1972,6 @@ class LMSXBlockServiceBindingTest(ModuleStoreTestCase):
super
(
LMSXBlockServiceBindingTest
,
self
)
.
setUp
()
super
(
LMSXBlockServiceBindingTest
,
self
)
.
setUp
()
self
.
user
=
UserFactory
()
self
.
user
=
UserFactory
()
self
.
student_data
=
Mock
()
self
.
student_data
=
Mock
()
self
.
course
=
CourseFactory
.
create
()
self
.
track_function
=
Mock
()
self
.
track_function
=
Mock
()
self
.
xqueue_callback_url_prefix
=
Mock
()
self
.
xqueue_callback_url_prefix
=
Mock
()
self
.
request_token
=
Mock
()
self
.
request_token
=
Mock
()
...
@@ -2012,16 +2046,21 @@ USER_NUMBERS = range(2)
...
@@ -2012,16 +2046,21 @@ USER_NUMBERS = range(2)
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
@ddt.ddt
class
TestFilteredChildren
(
ModuleStoreTestCase
):
class
TestFilteredChildren
(
Shared
ModuleStoreTestCase
):
"""
"""
Tests that verify access to XBlock/XModule children work correctly
Tests that verify access to XBlock/XModule children work correctly
even when those children are filtered by the runtime when loaded.
even when those children are filtered by the runtime when loaded.
"""
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestFilteredChildren
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
# pylint: disable=attribute-defined-outside-init, no-member
# pylint: disable=attribute-defined-outside-init, no-member
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestFilteredChildren
,
self
)
.
setUp
()
super
(
TestFilteredChildren
,
self
)
.
setUp
()
self
.
users
=
{
number
:
UserFactory
()
for
number
in
USER_NUMBERS
}
self
.
users
=
{
number
:
UserFactory
()
for
number
in
USER_NUMBERS
}
self
.
course
=
CourseFactory
()
self
.
_old_has_access
=
render
.
has_access
self
.
_old_has_access
=
render
.
has_access
patcher
=
patch
(
'courseware.module_render.has_access'
,
self
.
_has_access
)
patcher
=
patch
(
'courseware.module_render.has_access'
,
self
.
_has_access
)
...
...
lms/djangoapps/courseware/tests/test_navigation.py
View file @
ad9498ec
...
@@ -11,56 +11,60 @@ from django.test.utils import override_settings
...
@@ -11,56 +11,60 @@ from django.test.utils import override_settings
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.factories
import
GlobalStaffFactory
from
courseware.tests.factories
import
GlobalStaffFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestNavigation
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestNavigation
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Check that navigation state is saved properly.
Check that navigation state is saved properly.
"""
"""
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
),
(
'view2@test.com'
,
'foo'
)]
STUDENT_INFO
=
[(
'view@test.com'
,
'foo'
),
(
'view2@test.com'
,
'foo'
)]
def
setUp
(
self
):
@classmethod
super
(
TestNavigation
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
self
.
test_course
=
CourseFactory
.
create
()
super
(
TestNavigation
,
cls
)
.
setUpClass
()
self
.
course
=
CourseFactory
.
create
()
cls
.
test_course
=
CourseFactory
.
create
()
self
.
chapter0
=
ItemFactory
.
create
(
parent
=
self
.
course
,
cls
.
course
=
CourseFactory
.
create
()
cls
.
chapter0
=
ItemFactory
.
create
(
parent
=
cls
.
course
,
display_name
=
'Overview'
)
display_name
=
'Overview'
)
self
.
chapter9
=
ItemFactory
.
create
(
parent
=
self
.
course
,
cls
.
chapter9
=
ItemFactory
.
create
(
parent
=
cls
.
course
,
display_name
=
'factory_chapter'
)
display_name
=
'factory_chapter'
)
self
.
section0
=
ItemFactory
.
create
(
parent
=
self
.
chapter0
,
cls
.
section0
=
ItemFactory
.
create
(
parent
=
cls
.
chapter0
,
display_name
=
'Welcome'
)
display_name
=
'Welcome'
)
self
.
section9
=
ItemFactory
.
create
(
parent
=
self
.
chapter9
,
cls
.
section9
=
ItemFactory
.
create
(
parent
=
cls
.
chapter9
,
display_name
=
'factory_section'
)
display_name
=
'factory_section'
)
self
.
unit0
=
ItemFactory
.
create
(
parent
=
self
.
section0
,
cls
.
unit0
=
ItemFactory
.
create
(
parent
=
cls
.
section0
,
display_name
=
'New Unit'
)
display_name
=
'New Unit'
)
self
.
chapterchrome
=
ItemFactory
.
create
(
parent
=
self
.
course
,
cls
.
chapterchrome
=
ItemFactory
.
create
(
parent
=
cls
.
course
,
display_name
=
'Chrome'
)
display_name
=
'Chrome'
)
self
.
chromelesssection
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
cls
.
chromelesssection
=
ItemFactory
.
create
(
parent
=
cls
.
chapterchrome
,
display_name
=
'chromeless'
,
display_name
=
'chromeless'
,
chrome
=
'none'
)
chrome
=
'none'
)
self
.
accordionsection
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
cls
.
accordionsection
=
ItemFactory
.
create
(
parent
=
cls
.
chapterchrome
,
display_name
=
'accordion'
,
display_name
=
'accordion'
,
chrome
=
'accordion'
)
chrome
=
'accordion'
)
self
.
tabssection
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
cls
.
tabssection
=
ItemFactory
.
create
(
parent
=
cls
.
chapterchrome
,
display_name
=
'tabs'
,
display_name
=
'tabs'
,
chrome
=
'tabs'
)
chrome
=
'tabs'
)
self
.
defaultchromesection
=
ItemFactory
.
create
(
cls
.
defaultchromesection
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
parent
=
cls
.
chapterchrome
,
display_name
=
'defaultchrome'
,
display_name
=
'defaultchrome'
,
)
)
self
.
fullchromesection
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
cls
.
fullchromesection
=
ItemFactory
.
create
(
parent
=
cls
.
chapterchrome
,
display_name
=
'fullchrome'
,
display_name
=
'fullchrome'
,
chrome
=
'accordion,tabs'
)
chrome
=
'accordion,tabs'
)
self
.
tabtest
=
ItemFactory
.
create
(
parent
=
self
.
chapterchrome
,
cls
.
tabtest
=
ItemFactory
.
create
(
parent
=
cls
.
chapterchrome
,
display_name
=
'progress_tab'
,
display_name
=
'progress_tab'
,
default_tab
=
'progress'
)
default_tab
=
'progress'
)
def
setUp
(
self
):
super
(
TestNavigation
,
self
)
.
setUp
()
# Create student accounts and activate them.
# Create student accounts and activate them.
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
for
i
in
range
(
len
(
self
.
STUDENT_INFO
)):
email
,
password
=
self
.
STUDENT_INFO
[
i
]
email
,
password
=
self
.
STUDENT_INFO
[
i
]
...
...
lms/djangoapps/courseware/tests/test_split_module.py
View file @
ad9498ec
...
@@ -9,13 +9,13 @@ from courseware.module_render import get_module_for_descriptor
...
@@ -9,13 +9,13 @@ from courseware.module_render import get_module_for_descriptor
from
courseware.model_data
import
FieldDataCache
from
courseware.model_data
import
FieldDataCache
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
openedx.core.djangoapps.user_api.tests.factories
import
UserCourseTagFactory
from
openedx.core.djangoapps.user_api.tests.factories
import
UserCourseTagFactory
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
SplitTestBase
(
ModuleStoreTestCase
):
class
SplitTestBase
(
Shared
ModuleStoreTestCase
):
"""
"""
Sets up a basic course and user for split test testing.
Sets up a basic course and user for split test testing.
Also provides tests of rendered HTML for two user_tag conditions, 0 and 1.
Also provides tests of rendered HTML for two user_tag conditions, 0 and 1.
...
@@ -27,9 +27,10 @@ class SplitTestBase(ModuleStoreTestCase):
...
@@ -27,9 +27,10 @@ class SplitTestBase(ModuleStoreTestCase):
HIDDEN_CONTENT
=
None
HIDDEN_CONTENT
=
None
VISIBLE_CONTENT
=
None
VISIBLE_CONTENT
=
None
def
setUp
(
self
):
@classmethod
super
(
SplitTestBase
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
self
.
partition
=
UserPartition
(
super
(
SplitTestBase
,
cls
)
.
setUpClass
()
cls
.
partition
=
UserPartition
(
0
,
0
,
'first_partition'
,
'first_partition'
,
'First Partition'
,
'First Partition'
,
...
@@ -39,22 +40,25 @@ class SplitTestBase(ModuleStoreTestCase):
...
@@ -39,22 +40,25 @@ class SplitTestBase(ModuleStoreTestCase):
]
]
)
)
self
.
course
=
CourseFactory
.
create
(
cls
.
course
=
CourseFactory
.
create
(
number
=
self
.
COURSE_NUMBER
,
number
=
cls
.
COURSE_NUMBER
,
user_partitions
=
[
self
.
partition
]
user_partitions
=
[
cls
.
partition
]
)
)
self
.
chapter
=
ItemFactory
.
create
(
cls
.
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
category
=
"chapter"
,
category
=
"chapter"
,
display_name
=
"test chapter"
,
display_name
=
"test chapter"
,
)
)
self
.
sequential
=
ItemFactory
.
create
(
cls
.
sequential
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter
.
location
,
parent_location
=
cls
.
chapter
.
location
,
category
=
"sequential"
,
category
=
"sequential"
,
display_name
=
"Split Test Tests"
,
display_name
=
"Split Test Tests"
,
)
)
def
setUp
(
self
):
super
(
SplitTestBase
,
self
)
.
setUp
()
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
...
@@ -269,14 +273,14 @@ class TestSplitTestVert(SplitTestBase):
...
@@ -269,14 +273,14 @@ class TestSplitTestVert(SplitTestBase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
SplitTestPosition
(
ModuleStoreTestCase
):
class
SplitTestPosition
(
Shared
ModuleStoreTestCase
):
"""
"""
Check that we can change positions in a course with partitions defined
Check that we can change positions in a course with partitions defined
"""
"""
def
setUp
(
self
):
@classmethod
super
(
SplitTestPosition
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
super
(
SplitTestPosition
,
cls
)
.
setUpClass
()
self
.
partition
=
UserPartition
(
cls
.
partition
=
UserPartition
(
0
,
0
,
'first_partition'
,
'first_partition'
,
'First Partition'
,
'First Partition'
,
...
@@ -286,16 +290,19 @@ class SplitTestPosition(ModuleStoreTestCase):
...
@@ -286,16 +290,19 @@ class SplitTestPosition(ModuleStoreTestCase):
]
]
)
)
self
.
course
=
CourseFactory
.
create
(
cls
.
course
=
CourseFactory
.
create
(
user_partitions
=
[
self
.
partition
]
user_partitions
=
[
cls
.
partition
]
)
)
self
.
chapter
=
ItemFactory
.
create
(
cls
.
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
category
=
"chapter"
,
category
=
"chapter"
,
display_name
=
"test chapter"
,
display_name
=
"test chapter"
,
)
)
def
setUp
(
self
):
super
(
SplitTestPosition
,
self
)
.
setUp
()
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
...
...
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
ad9498ec
...
@@ -24,7 +24,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase
...
@@ -24,7 +24,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase
from
lms.djangoapps.lms_xblock.runtime
import
quote_slashes
from
lms.djangoapps.lms_xblock.runtime
import
quote_slashes
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
from
student.models
import
anonymous_id_for_user
from
student.models
import
anonymous_id_for_user
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
openedx.core.djangoapps.credit.api
import
(
from
openedx.core.djangoapps.credit.api
import
(
...
@@ -126,13 +126,10 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
...
@@ -126,13 +126,10 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
COURSE_NAME
=
"test_course"
COURSE_NAME
=
"test_course"
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestSubmittingProblems
,
self
)
.
setUp
()
super
(
TestSubmittingProblems
,
self
)
.
setUp
(
create_user
=
False
)
# Create course
self
.
course
=
CourseFactory
.
create
(
display_name
=
self
.
COURSE_NAME
,
number
=
self
.
COURSE_SLUG
)
assert
self
.
course
,
"Couldn't load course
%
r"
%
self
.
COURSE_NAME
# create a test student
# create a test student
self
.
course
=
CourseFactory
.
create
(
display_name
=
self
.
COURSE_NAME
,
number
=
self
.
COURSE_SLUG
)
self
.
student
=
'view@test.com'
self
.
student
=
'view@test.com'
self
.
password
=
'foo'
self
.
password
=
'foo'
self
.
create_account
(
'u1'
,
self
.
student
,
self
.
password
)
self
.
create_account
(
'u1'
,
self
.
student
,
self
.
password
)
...
...
lms/djangoapps/courseware/tests/test_tabs.py
View file @
ad9498ec
...
@@ -28,21 +28,25 @@ from util.milestones_helpers import (
...
@@ -28,21 +28,25 @@ from util.milestones_helpers import (
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
xmodule
import
tabs
as
xmodule_tabs
from
xmodule
import
tabs
as
xmodule_tabs
from
xmodule.modulestore.tests.django_utils
import
(
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_MIXED_CLOSED_MODULESTORE
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_MIXED_CLOSED_MODULESTORE
,
)
SharedModuleStoreTestCase
)
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
class
TabTestCase
(
ModuleStoreTestCase
):
class
TabTestCase
(
Shared
ModuleStoreTestCase
):
"""Base class for Tab-related test cases."""
"""Base class for Tab-related test cases."""
@classmethod
def
setUpClass
(
cls
):
super
(
TabTestCase
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
org
=
'edX'
,
course
=
'toy'
,
run
=
'2012_Fall'
)
cls
.
fake_dict_tab
=
{
'fake_key'
:
'fake_value'
}
cls
.
books
=
None
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TabTestCase
,
self
)
.
setUp
()
super
(
TabTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
org
=
'edX'
,
course
=
'toy'
,
run
=
'2012_Fall'
)
self
.
fake_dict_tab
=
{
'fake_key'
:
'fake_value'
}
self
.
reverse
=
lambda
name
,
args
:
"name/{0}/args/{1}"
.
format
(
name
,
","
.
join
(
str
(
a
)
for
a
in
args
))
self
.
reverse
=
lambda
name
,
args
:
"name/{0}/args/{1}"
.
format
(
name
,
","
.
join
(
str
(
a
)
for
a
in
args
))
self
.
books
=
None
def
create_mock_user
(
self
,
is_authenticated
=
True
,
is_staff
=
True
,
is_enrolled
=
True
):
def
create_mock_user
(
self
,
is_authenticated
=
True
,
is_staff
=
True
,
is_enrolled
=
True
):
"""
"""
...
@@ -219,21 +223,25 @@ class TextbooksTestCase(TabTestCase):
...
@@ -219,21 +223,25 @@ class TextbooksTestCase(TabTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
StaticTabDateTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
StaticTabDateTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""Test cases for Static Tab Dates."""
"""Test cases for Static Tab Dates."""
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
def
setUp
(
self
):
@classmethod
super
(
StaticTabDateTestCase
,
self
)
.
setUp
()
def
setUpClass
(
cls
):
self
.
course
=
CourseFactory
.
create
()
super
(
StaticTabDateTestCase
,
cls
)
.
setUpClass
()
self
.
page
=
ItemFactory
.
create
(
cls
.
course
=
CourseFactory
.
create
()
category
=
"static_tab"
,
parent_location
=
self
.
course
.
location
,
cls
.
page
=
ItemFactory
.
create
(
category
=
"static_tab"
,
parent_location
=
cls
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"new_tab"
data
=
"OOGIE BLOOGIE"
,
display_name
=
"new_tab"
)
)
self
.
course
.
tabs
.
append
(
xmodule_tabs
.
CourseTab
.
load
(
'static_tab'
,
name
=
'New Tab'
,
url_slug
=
'new_tab'
))
cls
.
course
.
tabs
.
append
(
xmodule_tabs
.
CourseTab
.
load
(
'static_tab'
,
name
=
'New Tab'
,
url_slug
=
'new_tab'
))
self
.
course
.
save
()
cls
.
course
.
save
()
self
.
toy_course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
cls
.
toy_course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
def
setUp
(
self
):
super
(
StaticTabDateTestCase
,
self
)
.
setUp
()
def
test_logged_in
(
self
):
def
test_logged_in
(
self
):
self
.
setup_user
()
self
.
setup_user
()
...
@@ -417,16 +425,20 @@ class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, Mi
...
@@ -417,16 +425,20 @@ class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, Mi
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TextBookCourseViewsTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
class
TextBookCourseViewsTestCase
(
LoginEnrollmentTestCase
,
Shared
ModuleStoreTestCase
):
"""
"""
Validate tab behavior when dealing with textbooks.
Validate tab behavior when dealing with textbooks.
"""
"""
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
@classmethod
def
setUpClass
(
cls
):
super
(
TextBookCourseViewsTestCase
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TextBookCourseViewsTestCase
,
self
)
.
setUp
()
super
(
TextBookCourseViewsTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
set_up_books
(
2
)
self
.
set_up_books
(
2
)
self
.
setup_user
()
self
.
setup_user
()
self
.
enroll
(
self
.
course
)
self
.
enroll
(
self
.
course
)
...
...
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