Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
c5368462
Commit
c5368462
authored
10 years ago
by
Don Mitchell
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for has_course
and negative tests for get_course.
parent
eacdc3b6
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+28
-2
28 additions, 2 deletions
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
with
28 additions
and
2 deletions
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+
28
−
2
View file @
c5368462
# pylint: disable=E0611
from
nose.tools
import
assert_equals
,
assert_raises
,
\
assert_not_equals
,
assert_false
,
assert_true
,
assert_greater
,
assert_is_instance
from
itertools
import
ifilter
assert_not_equals
,
assert_false
,
assert_true
,
assert_greater
,
assert_is_instance
,
assert_is_none
# pylint: enable=E0611
from
path
import
path
import
pymongo
...
...
@@ -157,6 +156,33 @@ class TestMongoModuleStore(unittest.TestCase):
assert_in
(
course_key
,
course_ids
)
course
=
self
.
store
.
get_course
(
course_key
)
assert_not_none
(
course
)
assert_true
(
self
.
store
.
has_course
(
course_key
))
mix_cased
=
SlashSeparatedCourseKey
(
course_key
.
org
.
upper
(),
course_key
.
course
.
upper
(),
course_key
.
run
.
lower
()
)
assert_false
(
self
.
store
.
has_course
(
mix_cased
))
assert_true
(
self
.
store
.
has_course
(
mix_cased
,
ignore_case
=
True
))
def
test_no_such_course
(
self
):
"""
Test get_course and has_course with ids which don
'
t exist
"""
for
course_key
in
[
SlashSeparatedCourseKey
(
*
fields
)
for
fields
in
[
[
'
edX
'
,
'
simple
'
,
'
no_such_course
'
],
[
'
edX
'
,
'
no_such_course
'
,
'
2012_Fall
'
],
[
'
NO_SUCH_COURSE
'
,
'
Test_iMport_courSe
'
,
'
2012_Fall
'
],
]
]:
course
=
self
.
store
.
get_course
(
course_key
)
assert_is_none
(
course
)
assert_false
(
self
.
store
.
has_course
(
course_key
))
mix_cased
=
SlashSeparatedCourseKey
(
course_key
.
org
.
lower
(),
course_key
.
course
.
upper
(),
course_key
.
run
.
upper
()
)
assert_false
(
self
.
store
.
has_course
(
mix_cased
))
assert_false
(
self
.
store
.
has_course
(
mix_cased
,
ignore_case
=
True
))
def
test_loads
(
self
):
assert_not_none
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment