Commit 4a8af859 by David Ormsbee

Merge pull request #22 from edx/ormsbee/fix_urls

URL change: /video -> /videos, added /admin
parents e7eb2ad0 c3375ad3
...@@ -155,7 +155,7 @@ def get_video_info(edx_video_id, location=None): # pylint: disable=W0613 ...@@ -155,7 +155,7 @@ def get_video_info(edx_video_id, location=None): # pylint: disable=W0613
>>> get_video_info("example") >>> get_video_info("example")
Returns (dict): Returns (dict):
{ {
'url' : '/edxval/video/example', 'url' : '/edxval/videos/example',
'edx_video_id': u'example', 'edx_video_id': u'example',
'duration': 111.0, 'duration': 111.0,
'client_video_id': u'The example video', 'client_video_id': u'The example video',
......
...@@ -103,7 +103,7 @@ MIDDLEWARE_CLASSES = ( ...@@ -103,7 +103,7 @@ MIDDLEWARE_CLASSES = (
# 'django.middleware.clickjacking.XFrameOptionsMiddleware', # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )
ROOT_URLCONF = 'edxval.urls' ROOT_URLCONF = 'urls'
# Python dotted path to the WSGI application used by Django's runserver. # Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'edxval.wsgi.application' WSGI_APPLICATION = 'edxval.wsgi.application'
......
...@@ -335,7 +335,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -335,7 +335,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.COMPLETE_SET_FISH, format='json' url, constants.COMPLETE_SET_FISH, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 1) self.assertEqual(len(video), 1)
self.assertEqual(len(video[0].get("encoded_videos")), 2) self.assertEqual(len(video[0].get("encoded_videos")), 2)
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
...@@ -349,7 +349,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -349,7 +349,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.COMPLETE_SET_EXTRA_VIDEO_FIELD, format='json' url, constants.COMPLETE_SET_EXTRA_VIDEO_FIELD, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 1) self.assertEqual(len(video), 1)
edx_video_id = constants.VIDEO_DICT_STAR.get("edx_video_id") edx_video_id = constants.VIDEO_DICT_STAR.get("edx_video_id")
self.assertEqual(video[0].get("edx_video_id"), edx_video_id) self.assertEqual(video[0].get("edx_video_id"), edx_video_id)
...@@ -363,7 +363,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -363,7 +363,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.VIDEO_DICT_ANIMAL, format='json' url, constants.VIDEO_DICT_ANIMAL, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 1) self.assertEqual(len(video), 1)
self.assertEqual(len(video[0].get("encoded_videos")), 0) self.assertEqual(len(video[0].get("encoded_videos")), 0)
...@@ -386,7 +386,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -386,7 +386,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.VIDEO_DICT_ANIMAL, format='json' url, constants.VIDEO_DICT_ANIMAL, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
videos = len(self.client.get("/edxval/video/").data) videos = len(self.client.get("/edxval/videos/").data)
self.assertEqual(videos, 1) self.assertEqual(videos, 1)
response = self.client.post( response = self.client.post(
url, constants.VIDEO_DICT_ANIMAL, format='json' url, constants.VIDEO_DICT_ANIMAL, format='json'
...@@ -396,7 +396,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -396,7 +396,7 @@ class VideoListTest(APIAuthTestCase):
response.data.get("edx_video_id")[0], response.data.get("edx_video_id")[0],
"Video with this Edx video id already exists." "Video with this Edx video id already exists."
) )
videos = len(self.client.get("/edxval/video/").data) videos = len(self.client.get("/edxval/videos/").data)
self.assertEqual(videos, 1) self.assertEqual(videos, 1)
def test_post_with_youtube(self): def test_post_with_youtube(self):
...@@ -417,7 +417,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -417,7 +417,7 @@ class VideoListTest(APIAuthTestCase):
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
videos = self.client.get("/edxval/video/").data videos = self.client.get("/edxval/videos/").data
self.assertEqual(len(videos), 1) self.assertEqual(len(videos), 1)
self.assertIn('youtube.com', videos[0]['encoded_videos'][1]['url']) self.assertIn('youtube.com', videos[0]['encoded_videos'][1]['url'])
...@@ -430,7 +430,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -430,7 +430,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.COMPLETE_SET_INVALID_ENCODED_VIDEO_FISH, format='json' url, constants.COMPLETE_SET_INVALID_ENCODED_VIDEO_FISH, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 0) self.assertEqual(len(video), 0)
def test_complete_set_invalid_video_post(self): def test_complete_set_invalid_video_post(self):
...@@ -442,7 +442,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -442,7 +442,7 @@ class VideoListTest(APIAuthTestCase):
url, constants.COMPLETE_SET_INVALID_VIDEO_FISH, format='json' url, constants.COMPLETE_SET_INVALID_VIDEO_FISH, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 0) self.assertEqual(len(video), 0)
self.assertEqual( self.assertEqual(
response.data.get("edx_video_id")[0], response.data.get("edx_video_id")[0],
...@@ -490,7 +490,7 @@ class VideoListTest(APIAuthTestCase): ...@@ -490,7 +490,7 @@ class VideoListTest(APIAuthTestCase):
url, video, format='json' url, video, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
videos = self.client.get("/edxval/video/").data videos = self.client.get("/edxval/videos/").data
self.assertEqual(len(videos), 1) self.assertEqual(len(videos), 1)
self.assertEqual(videos[0]['courses'], [course1, course2]) self.assertEqual(videos[0]['courses'], [course1, course2])
...@@ -551,7 +551,7 @@ class VideoDetailTest(APIAuthTestCase): ...@@ -551,7 +551,7 @@ class VideoDetailTest(APIAuthTestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
response = self.client.post(url, constants.VIDEO_DICT_ZEBRA, format='json') response = self.client.post(url, constants.VIDEO_DICT_ZEBRA, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
videos = self.client.get("/edxval/video/").data videos = self.client.get("/edxval/videos/").data
self.assertEqual(len(videos), 2) self.assertEqual(len(videos), 2)
def test_queries_for_get(self): def test_queries_for_get(self):
...@@ -564,15 +564,15 @@ class VideoDetailTest(APIAuthTestCase): ...@@ -564,15 +564,15 @@ class VideoDetailTest(APIAuthTestCase):
response = self.client.post(url, constants.VIDEO_DICT_ZEBRA, format='json') response = self.client.post(url, constants.VIDEO_DICT_ZEBRA, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
with self.assertNumQueries(7): with self.assertNumQueries(7):
self.client.get("/edxval/video/").data self.client.get("/edxval/videos/").data
response = self.client.post(url, constants.COMPLETE_SET_FISH, format='json') response = self.client.post(url, constants.COMPLETE_SET_FISH, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
with self.assertNumQueries(12): with self.assertNumQueries(12):
self.client.get("/edxval/video/").data self.client.get("/edxval/videos/").data
response = self.client.post(url, constants.COMPLETE_SET_STAR, format='json') response = self.client.post(url, constants.COMPLETE_SET_STAR, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
with self.assertNumQueries(15): with self.assertNumQueries(15):
self.client.get("/edxval/video/").data self.client.get("/edxval/videos/").data
class SubtitleDetailTest(APIAuthTestCase): class SubtitleDetailTest(APIAuthTestCase):
...@@ -593,7 +593,7 @@ class SubtitleDetailTest(APIAuthTestCase): ...@@ -593,7 +593,7 @@ class SubtitleDetailTest(APIAuthTestCase):
url, constants.COMPLETE_SET_FISH, format='json' url, constants.COMPLETE_SET_FISH, format='json'
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
video = self.client.get("/edxval/video/").data video = self.client.get("/edxval/videos/").data
self.assertEqual(len(video), 1) self.assertEqual(len(video), 1)
self.assertEqual(len(video[0].get("subtitles")), 2) self.assertEqual(len(video[0].get("subtitles")), 2)
......
...@@ -10,27 +10,27 @@ from edxval import views ...@@ -10,27 +10,27 @@ from edxval import views
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url( url(
r'^edxval/video/$', r'^videos/$',
views.VideoList.as_view(), views.VideoList.as_view(),
name="video-list" name="video-list"
), ),
url( url(
r'^edxval/video/(?P<edx_video_id>[-\w]+)$', r'^videos/(?P<edx_video_id>[-\w]+)$',
views.VideoDetail.as_view(), views.VideoDetail.as_view(),
name="video-detail" name="video-detail"
), ),
url( url(
r'^edxval/video/(?P<video__edx_video_id>[-\w]+)/(?P<language>[-_\w]+)$', r'^videos/(?P<video__edx_video_id>[-\w]+)/(?P<language>[-_\w]+)$',
views.SubtitleDetail.as_view(), views.SubtitleDetail.as_view(),
name="subtitle-detail" name="subtitle-detail"
), ),
url( url(
r'^edxval/video/(?P<edx_video_id>[-\w]+)/(?P<language>[-_\w]+)/subtitle$', r'^videos/(?P<edx_video_id>[-\w]+)/(?P<language>[-_\w]+)/subtitle$',
views.get_subtitle, views.get_subtitle,
name="subtitle-content" name="subtitle-content"
), ),
url( url(
r'^edxval/course/{}$'.format(settings.COURSE_ID_PATTERN), r'^courses/{}$'.format(settings.COURSE_ID_PATTERN),
views.CourseVideoList.as_view(), views.CourseVideoList.as_view(),
name="course-video-list" name="course-video-list"
), ),
......
from django.conf import settings
from django.conf.urls import patterns, include, url from django.conf.urls import patterns, include, url
from django.contrib import admin
from edxval import views admin.autodiscover()
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url( # Django Admin
r'^video/$', url(r'^admin/', include(admin.site.urls)),
views.VideoList.as_view(),
name="video_view" # edx-val
), url(r'^edxval/', include('edxval.urls'))
url(
r'^video/(?P<edx_video_id>\w+)',
views.VideoDetail.as_view(),
name="video_detail_view"
)
) )
# We need to do explicit setup of the Django debug toolbar because autodiscovery
# causes problems when you mix debug toolbar >= 1.0 + django < 1.7, and the
# admin uses autodiscovery. See:
# http://django-debug-toolbar.readthedocs.org/en/1.0/installation.html#explicit-setup
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^__debug__/', include('debug_toolbar.urls')),
)
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