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
bc34d79d
Commit
bc34d79d
authored
Nov 09, 2012
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve assertions by using HTML matchers.
parent
58eea1bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
cms/djangoapps/contentstore/tests/tests.py
+23
-16
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
bc34d79d
...
@@ -199,7 +199,6 @@ class ContentStoreTest(TestCase):
...
@@ -199,7 +199,6 @@ class ContentStoreTest(TestCase):
self
.
user
.
is_staff
=
True
self
.
user
.
is_staff
=
True
self
.
user
.
save
()
self
.
user
.
save
()
# Flush and initialize the module store
# Flush and initialize the module store
# It needs the templates because it creates new records
# It needs the templates because it creates new records
# by cloning from the template.
# by cloning from the template.
...
@@ -238,6 +237,17 @@ class ContentStoreTest(TestCase):
...
@@ -238,6 +237,17 @@ class ContentStoreTest(TestCase):
'display_name'
:
'Section One'
,
'display_name'
:
'Section One'
,
}
}
def
tearDown
(
self
):
# Make sure you flush out the test modulestore after the end
# of the last test otherwise cms/djangoapps/contentstore/__init__.py
# update_templates() is complaining that there are duplicate
# templates.
# If your test module gets in some weird state, do this manually
# from the bash shell to drop it.
# $ mongo test_xmodule --eval "db.dropDatabase()"
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
def
test_create_course
(
self
):
def
test_create_course
(
self
):
"""Test new course creation - happy path"""
"""Test new course creation - happy path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
...
@@ -269,24 +279,20 @@ class ContentStoreTest(TestCase):
...
@@ -269,24 +279,20 @@ class ContentStoreTest(TestCase):
"""Test viewing the index page with no courses"""
"""Test viewing the index page with no courses"""
# Create a course so there is something to view
# Create a course so there is something to view
resp
=
self
.
client
.
get
(
reverse
(
'index'
))
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, make a better matcher below. JZ 11/08/2012
self
.
assertContains
(
resp
,
self
.
assertContains
(
resp
,
'<a href="#" class="new-course-button"><span class="plus-icon"></span> New Course</a>'
,
'<h1>My Courses</h1>'
,
html
=
False
)
status_code
=
200
,
html
=
True
)
def
test_course_index_view_with_course
(
self
):
def
test_course_index_view_with_course
(
self
):
"""Test viewing the index page with an existing course"""
"""Test viewing the index page with an existing course"""
# Create a course so there is something to view
# Create a course so there is something to view
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
resp
=
self
.
client
.
get
(
reverse
(
'index'
))
resp
=
self
.
client
.
get
(
reverse
(
'index'
))
self
.
assertContains
(
resp
,
# Right now there may be a bug in cms/templates/widgets/header.html
'<span class="class-name">Robot Super Course</span>'
,
# because there is an unexpected ending ul tag in the header.
status_code
=
200
,
# When this is fixed, change html=True below. JZ 11/08/2012
html
=
True
)
self
.
assertContains
(
resp
,
'<span class="class-name">Robot Super Course</span>'
,
html
=
False
)
def
test_course_overview_view_with_course
(
self
):
def
test_course_overview_view_with_course
(
self
):
"""Test viewing the course overview page with an existing course"""
"""Test viewing the course overview page with an existing course"""
...
@@ -300,12 +306,10 @@ class ContentStoreTest(TestCase):
...
@@ -300,12 +306,10 @@ class ContentStoreTest(TestCase):
}
}
resp
=
self
.
client
.
get
(
reverse
(
'course_index'
,
kwargs
=
data
))
resp
=
self
.
client
.
get
(
reverse
(
'course_index'
,
kwargs
=
data
))
# 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
,
self
.
assertContains
(
resp
,
'<a href="/MITx/999/course/Robot_Super_Course" class="class-name">Robot Super Course</a>'
,
'<a href="/MITx/999/course/Robot_Super_Course" class="class-name">Robot Super Course</a>'
,
html
=
False
)
status_code
=
200
,
html
=
True
)
def
test_clone_item
(
self
):
def
test_clone_item
(
self
):
"""Test cloning an item. E.g. creating a new section"""
"""Test cloning an item. E.g. creating a new section"""
...
@@ -327,6 +331,9 @@ class ContentStoreTest(TestCase):
...
@@ -327,6 +331,9 @@ class ContentStoreTest(TestCase):
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
modulestore
()
.
collection
.
drop
()
def
test_edit_unit_toy
(
self
):
def
test_edit_unit_toy
(
self
):
self
.
check_edit_unit
(
'toy'
)
self
.
check_edit_unit
(
'toy'
)
...
...
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