-fixed failing tests
-Adressed all comments
This commit is contained in:
@@ -91,7 +91,7 @@ from util.organizations_helpers import (
|
||||
organizations_enabled,
|
||||
)
|
||||
from util.string_utils import _has_non_ascii_characters
|
||||
from util.course_key_utils import from_string_or_404
|
||||
from util.course_key_utils import course_key_from_string_or_404
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from xmodule.course_module import CourseFields
|
||||
from xmodule.course_module import DEFAULT_START_DATE
|
||||
@@ -875,7 +875,7 @@ def course_info_handler(request, course_key_string):
|
||||
GET
|
||||
html: return html for editing the course info handouts and updates.
|
||||
"""
|
||||
course_key = from_string_or_404(course_key_string)
|
||||
course_key = course_key_from_string_or_404(course_key_string)
|
||||
|
||||
with modulestore().bulk_operations(course_key):
|
||||
course_module = get_course_and_check_access(course_key, request.user)
|
||||
|
||||
@@ -199,7 +199,6 @@ class TabsPageTests(CourseTestCase):
|
||||
self.client.get(invalid_tab_url)
|
||||
|
||||
|
||||
|
||||
class PrimitiveTabEdit(ModuleStoreTestCase):
|
||||
"""Tests for the primitive tab edit data manipulations"""
|
||||
|
||||
|
||||
@@ -28,4 +28,4 @@ def course_key_from_string_or_404(course_key_string, message=None):
|
||||
except InvalidKeyError:
|
||||
raise Http404(message)
|
||||
|
||||
return course_key
|
||||
return course_key
|
||||
|
||||
@@ -14,22 +14,32 @@ class TestFromStringOr404(unittest.TestCase):
|
||||
Base Test class for course_key_from_string_or_404 utility tests
|
||||
"""
|
||||
@ddt.data(
|
||||
("/some.invalid.key/course-v1:TTT+CS01+2015_T0", "course-v1:TTT+CS01+2015_T0"), # split style course keys
|
||||
("/some.invalid.key/TTT/CS01/2015_T0", "TTT/CS01/2015_T0"), # mongo style course keys
|
||||
"course-v1:TTT+CS01+2015_T0", # split style course keys
|
||||
"TTT/CS01/2015_T0" # mongo style course keys
|
||||
)
|
||||
def test_from_string_or_404(self, (invalid_course_key, valid_course_key)):
|
||||
def test_from_string_or_404_for_valid_course_key(self, valid_course_key):
|
||||
"""
|
||||
Tests course_key_from_string_or_404 for valid and invalid split style course keys and mongo style course keys.
|
||||
Tests course_key_from_string_or_404 for valid split style course keys and mongo style course keys.
|
||||
"""
|
||||
from nose.tools import set_trace ; set_trace()
|
||||
self.assertEquals(
|
||||
CourseKey.from_string(valid_course_key),
|
||||
course_key_from_string_or_404(valid_course_key)
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
"/some.invalid.key/course-v1:TTT+CS01+2015_T0", # split style course keys
|
||||
"/some.invalid.key/TTT/CS01/2015_T0" # mongo style course keys
|
||||
)
|
||||
def test_from_string_or_404_for_invalid_course_key(self, invalid_course_key):
|
||||
"""
|
||||
Tests course_key_from_string_or_404 for valid split style course keys and mongo style course keys.
|
||||
"""
|
||||
self.assertRaises(
|
||||
Http404,
|
||||
course_key_from_string_or_404,
|
||||
invalid_course_key,
|
||||
)
|
||||
self.assertEquals(
|
||||
CourseKey.from_string(valid_course_key),
|
||||
course_key_from_string_or_404(valid_course_key)
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
"/some.invalid.key/course-v1:TTT+CS01+2015_T0", # split style invalid course key
|
||||
@@ -40,7 +50,6 @@ class TestFromStringOr404(unittest.TestCase):
|
||||
Tests course_key_from_string_or_404 with exception message for split style and monog style invalid course keys.
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
with self.assertRaises(Http404) as context:
|
||||
course_key_from_string_or_404(course_string, message="Invalid Keys")
|
||||
except Http404 as exception:
|
||||
self.assertEquals(str(exception), "Invalid Keys")
|
||||
self.assertEquals(str(context.exception), "Invalid Keys")
|
||||
|
||||
@@ -1318,8 +1318,9 @@ class InlineDiscussionUnicodeTestCase(SharedModuleStoreTestCase, UnicodeTestMixi
|
||||
request.user = self.student
|
||||
with self.assertRaises(Http404):
|
||||
views.inline_discussion(
|
||||
request, self.course.id.to_deprecated_string(), self.course.discussion_topics['General']['id']
|
||||
)
|
||||
request, unicode(self.course.id), self.course.discussion_topics['General']['id']
|
||||
)
|
||||
|
||||
|
||||
class ForumFormDiscussionUnicodeTestCase(SharedModuleStoreTestCase, UnicodeTestMixin):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user