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
2077f62d
Commit
2077f62d
authored
Nov 08, 2012
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for index page, plus SOUTH migrations for faster test execution.
parent
50a8cf4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
38 deletions
+50
-38
cms/djangoapps/contentstore/tests/tests.py
+47
-38
cms/envs/test.py
+3
-0
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
2077f62d
...
@@ -182,56 +182,31 @@ TEST_DATA_MODULESTORE['default']['OPTIONS']['fs_root'] = path('common/test/data'
...
@@ -182,56 +182,31 @@ TEST_DATA_MODULESTORE['default']['OPTIONS']['fs_root'] = path('common/test/data'
TEST_DATA_MODULESTORE
[
'direct'
][
'OPTIONS'
][
'fs_root'
]
=
path
(
'common/test/data'
)
TEST_DATA_MODULESTORE
[
'direct'
][
'OPTIONS'
][
'fs_root'
]
=
path
(
'common/test/data'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MODULESTORE
)
class
EditTestCase
(
ContentStoreTestCase
):
class
ContentStoreTest
(
TestCase
):
"""Check that editing functionality works on example courses"""
def
setUp
(
self
):
email
=
'edit@test.com'
password
=
'foo'
self
.
create_account
(
'edittest'
,
email
,
password
)
self
.
activate_user
(
email
)
self
.
login
(
email
,
password
)
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
def
check_edit_unit
(
self
,
test_course_name
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
test_course_name
])
for
descriptor
in
modulestore
()
.
get_items
(
Location
(
None
,
None
,
'vertical'
,
None
,
None
)):
print
"Checking "
,
descriptor
.
location
.
url
()
print
descriptor
.
__class__
,
descriptor
.
location
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_edit_unit_toy
(
self
):
self
.
check_edit_unit
(
'toy'
)
def
test_edit_unit_full
(
self
):
self
.
check_edit_unit
(
'full'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MODULESTORE
)
class
CourseCreationTest
(
ContentStoreTestCase
):
"""Test new course creation code"""
def
setUp
(
self
):
def
setUp
(
self
):
uname
=
'testuser'
uname
=
'testuser'
email
=
'
edit@test.com
'
email
=
'
test+courses@edx.org
'
password
=
'foo'
password
=
'foo'
# Create the use so we can log them in.
# Create the use so we can log them in.
# Note that we do not actually need to do anything
# Note that we do not actually need to do anything
# for registration if we directly mark them active.
# for registration if we directly mark them active.
u
=
User
.
objects
.
create_user
(
uname
,
email
,
password
)
self
.
user
=
User
.
objects
.
create_user
(
uname
,
email
,
password
)
u
.
is_active
=
True
self
.
user
.
is_active
=
True
u
.
save
()
self
.
user
.
save
()
# Flush and initialize the module store
# Flush and initialize the module store
# It needs a course template because it creates a new course
# It needs a course template because it creates a new course
# by cloning from the template.
# by cloning from the template.
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
template_item
=
{
'_id'
:
{
'tag'
:
'i4x'
,
'org'
:
'edx'
,
'course'
:
'templates'
,
template_item
=
{
"_id"
:
{
"tag"
:
"i4x"
,
"org"
:
"edx"
,
"course"
:
"templates"
,
'category'
:
'course'
,
'name'
:
'Empty'
,
'revision'
:
None
}}
"category"
:
"course"
,
"name"
:
"Empty"
,
"revision"
:
None
},
"definition"
:
{
"children"
:
[
],
"data"
:
{
"textbooks"
:
[
],
"wiki_slug"
:
None
}
},
"metadata"
:
{
"start"
:
"2020-10-10T10:00"
,
"display_name"
:
"Empty"
}
}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
insert
(
template_item
)
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
insert
(
template_item
)
self
.
client
=
Client
()
self
.
client
=
Client
()
...
@@ -245,12 +220,14 @@ class CourseCreationTest(ContentStoreTestCase):
...
@@ -245,12 +220,14 @@ class CourseCreationTest(ContentStoreTestCase):
}
}
def
test_create_course
(
self
):
def
test_create_course
(
self
):
"""Test new course creation - happy path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
data
=
parse_json
(
resp
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
def
test_create_course_duplicate_course
(
self
):
def
test_create_course_duplicate_course
(
self
):
"""Test new course creation - error path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
data
=
parse_json
(
resp
)
data
=
parse_json
(
resp
)
...
@@ -258,6 +235,7 @@ class CourseCreationTest(ContentStoreTestCase):
...
@@ -258,6 +235,7 @@ class CourseCreationTest(ContentStoreTestCase):
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with this name.'
)
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with this name.'
)
def
test_create_course_duplicate_number
(
self
):
def
test_create_course_duplicate_number
(
self
):
"""Test new course creation - error path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
self
.
post_data
[
'display_name'
]
=
'Robot Super Course Two'
self
.
post_data
[
'display_name'
]
=
'Robot Super Course Two'
...
@@ -265,4 +243,35 @@ class CourseCreationTest(ContentStoreTestCase):
...
@@ -265,4 +243,35 @@ class CourseCreationTest(ContentStoreTestCase):
data
=
parse_json
(
resp
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with the same organization and course number.'
)
self
.
assertEqual
(
data
[
'ErrMsg'
],
'There is already a course defined with the same organization and course number.'
)
\ No newline at end of file
def
test_index
(
self
):
"""Test viewing the existing courses"""
# Staff has access to view all courses
self
.
user
.
is_staff
=
True
self
.
user
.
save
()
# Create a course so there is something to view
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
post_data
)
resp
=
self
.
client
.
get
(
reverse
(
'index'
))
# Right now there may be a bug in cms/templates/widgets/header.html
# because there is an unexpected ending ul tag in the header.
# When this is fixed, change html=True below. JZ 11/08/2012
self
.
assertContains
(
resp
,
'<span class="class-name">Robot Super Course</span>'
,
html
=
False
)
def
check_edit_unit
(
self
,
test_course_name
):
"""Check that editing functionality works on example courses"""
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
test_course_name
])
for
descriptor
in
modulestore
()
.
get_items
(
Location
(
None
,
None
,
'vertical'
,
None
,
None
)):
print
"Checking "
,
descriptor
.
location
.
url
()
print
descriptor
.
__class__
,
descriptor
.
location
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_edit_unit_toy
(
self
):
self
.
check_edit_unit
(
'toy'
)
def
test_edit_unit_full
(
self
):
self
.
check_edit_unit
(
'full'
)
\ No newline at end of file
cms/envs/test.py
View file @
2077f62d
...
@@ -21,6 +21,9 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
...
@@ -21,6 +21,9 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
TEST_ROOT
=
path
(
'test_root'
)
TEST_ROOT
=
path
(
'test_root'
)
# Makes the tests run much faster...
SOUTH_TESTS_MIGRATE
=
False
# To disable migrations and use syncdb instead
# Want static files in the same dir for running on jenkins.
# Want static files in the same dir for running on jenkins.
STATIC_ROOT
=
TEST_ROOT
/
"staticfiles"
STATIC_ROOT
=
TEST_ROOT
/
"staticfiles"
...
...
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