Commit d62a05e8 by Dave St.Germain

Merge pull request #19 from edx/dcs/course_id

Use the correct course_id regex.
parents 73456f89 15a69c59
...@@ -169,3 +169,7 @@ LOGGING = { ...@@ -169,3 +169,7 @@ LOGGING = {
}, },
} }
} }
# copied from edx-platform
COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/]+)'
COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id')
...@@ -460,8 +460,8 @@ class VideoListTest(APIAuthTestCase): ...@@ -460,8 +460,8 @@ class VideoListTest(APIAuthTestCase):
""" """
url = reverse('video-list') url = reverse('video-list')
video = dict(**constants.VIDEO_DICT_ANIMAL) video = dict(**constants.VIDEO_DICT_ANIMAL)
course1 = 'animals/fish' course1 = 'animals/fish/carp'
course2 = 'animals/birds' course2 = 'animals/birds/cardinal'
video['courses'] = [course1, course2] video['courses'] = [course1, course2]
response = self.client.post( response = self.client.post(
...@@ -477,7 +477,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -477,7 +477,7 @@ class VideoListTest(APIAuthTestCase):
self.assertEqual(len(videos), 1) self.assertEqual(len(videos), 1)
self.assertEqual(videos[0]['edx_video_id'], constants.VIDEO_DICT_ANIMAL['edx_video_id']) self.assertEqual(videos[0]['edx_video_id'], constants.VIDEO_DICT_ANIMAL['edx_video_id'])
url = reverse('course-video-list', kwargs={'course_id': course1 + '/bad'}) url = reverse('course-video-list', kwargs={'course_id': 'animals/fish/salmon'})
response = self.client.get(url).data response = self.client.get(url).data
self.assertEqual(len(response), 0) self.assertEqual(len(response), 0)
......
...@@ -3,6 +3,7 @@ Url file for django app edxval. ...@@ -3,6 +3,7 @@ Url file for django app edxval.
""" """
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from django.conf import settings
from edxval import views from edxval import views
...@@ -29,7 +30,7 @@ urlpatterns = patterns( ...@@ -29,7 +30,7 @@ urlpatterns = patterns(
name="subtitle-content" name="subtitle-content"
), ),
url( url(
r'^edxval/course/(?P<course_id>[-\w/]+)$', r'^edxval/course/{}$'.format(settings.COURSE_ID_PATTERN),
views.CourseVideoList.as_view(), views.CourseVideoList.as_view(),
name="course-video-list" name="course-video-list"
), ),
......
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