Commit ca66d982 by Don Mitchell

Merge pull request #3900 from edx/dhm/test_has_course

Add tests for has_course
parents eeac479c 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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment