Merge pull request #3900 from edx/dhm/test_has_course
Add tests for has_course
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# pylint: disable=E0611
|
# pylint: disable=E0611
|
||||||
from nose.tools import assert_equals, assert_raises, \
|
from nose.tools import assert_equals, assert_raises, \
|
||||||
assert_not_equals, assert_false, assert_true, assert_greater, assert_is_instance
|
assert_not_equals, assert_false, assert_true, assert_greater, assert_is_instance, assert_is_none
|
||||||
from itertools import ifilter
|
|
||||||
# pylint: enable=E0611
|
# pylint: enable=E0611
|
||||||
from path import path
|
from path import path
|
||||||
import pymongo
|
import pymongo
|
||||||
@@ -157,6 +156,33 @@ class TestMongoModuleStore(unittest.TestCase):
|
|||||||
assert_in(course_key, course_ids)
|
assert_in(course_key, course_ids)
|
||||||
course = self.store.get_course(course_key)
|
course = self.store.get_course(course_key)
|
||||||
assert_not_none(course)
|
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):
|
def test_loads(self):
|
||||||
assert_not_none(
|
assert_not_none(
|
||||||
|
|||||||
Reference in New Issue
Block a user