tighten case-insensitive test to require full string match
This commit is contained in:
@@ -1450,6 +1450,20 @@ class ContentStoreTest(ModuleStoreTestCase):
|
||||
self.course_data['number'] = self.course_data['number'].upper()
|
||||
self.assert_course_creation_failed('There is already a course defined with the same organization and course number. Please change at least one field to be unique.')
|
||||
|
||||
def test_course_substring(self):
|
||||
"""
|
||||
Test that a new course can be created whose name is a substring of an existing course
|
||||
"""
|
||||
self.client.post(reverse('create_new_course'), self.course_data)
|
||||
cache_current = self.course_data['number']
|
||||
self.course_data['number'] = '{}a'.format(self.course_data['number'])
|
||||
resp = self.client.post(reverse('create_new_course'), self.course_data)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.course_data['number'] = cache_current
|
||||
self.course_data['org'] = 'a{}'.format(self.course_data['org'])
|
||||
resp = self.client.post(reverse('create_new_course'), self.course_data)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
def test_create_course_with_bad_organization(self):
|
||||
"""Test new course creation - error path for bad organization name"""
|
||||
self.course_data['org'] = 'University of California, Berkeley'
|
||||
|
||||
@@ -204,8 +204,8 @@ def create_new_course(request):
|
||||
course_search_location = bson.son.SON({
|
||||
'_id.tag': 'i4x',
|
||||
# cannot pass regex to Location constructor; thus this hack
|
||||
'_id.org': re.compile(dest_location.org, re.IGNORECASE),
|
||||
'_id.course': re.compile(dest_location.course, re.IGNORECASE),
|
||||
'_id.org': re.compile('^{}$'.format(dest_location.org), re.IGNORECASE),
|
||||
'_id.course': re.compile('^{}$'.format(dest_location.course), re.IGNORECASE),
|
||||
'_id.category': 'course',
|
||||
})
|
||||
courses = modulestore().collection.find(course_search_location, fields=('_id'))
|
||||
|
||||
Reference in New Issue
Block a user