Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-val
Commits
7d4242df
Commit
7d4242df
authored
Sep 09, 2015
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regression tests in preparation for the Django Rest Framework upgrade
parent
c0c975f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
1 deletions
+105
-1
edxval/tests/constants.py
+16
-0
edxval/tests/test_views.py
+89
-1
No files found.
edxval/tests/constants.py
View file @
7d4242df
...
@@ -268,6 +268,22 @@ COMPLETE_SET_UPDATE_STAR = dict(
...
@@ -268,6 +268,22 @@ COMPLETE_SET_UPDATE_STAR = dict(
subtitles
=
[
SUBTITLE_DICT_SRT
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
**
VIDEO_DICT_STAR
)
)
COMPLETE_SET_WITH_COURSE_KEY
=
dict
(
courses
=
[
'edX/DemoX/Demo_Course'
],
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_OTHER_COURSE_KEYS
=
dict
(
courses
=
[
'edX/DemoX/Astonomy'
,
'edX/DemoX/Zoology'
],
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_NOT_A_LIST
=
dict
(
COMPLETE_SET_NOT_A_LIST
=
dict
(
encoded_videos
=
dict
(
encoded_videos
=
dict
(
url
=
"https://www.howIwonder.com"
,
url
=
"https://www.howIwonder.com"
,
...
...
edxval/tests/test_views.py
View file @
7d4242df
...
@@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
...
@@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
from
rest_framework
import
status
from
rest_framework
import
status
from
edxval.tests
import
constants
,
APIAuthTestCase
from
edxval.tests
import
constants
,
APIAuthTestCase
from
edxval.models
import
Profile
,
Video
from
edxval.models
import
Profile
,
Video
,
CourseVideo
class
VideoDetail
(
APIAuthTestCase
):
class
VideoDetail
(
APIAuthTestCase
):
...
@@ -207,6 +207,86 @@ class VideoDetail(APIAuthTestCase):
...
@@ -207,6 +207,86 @@ class VideoDetail(APIAuthTestCase):
)
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
encoded_videos
.
all
()),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
encoded_videos
.
all
()),
1
)
def
test_update_remove_subtitles
(
self
):
# Create some subtitles
self
.
_create_videos
(
constants
.
COMPLETE_SET_STAR
)
# Sanity check that the subtitles have been created
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
subtitles
.
all
()),
1
)
# Update with an empty list of subtitles
url
=
reverse
(
'video-detail'
,
kwargs
=
{
"edx_video_id"
:
constants
.
COMPLETE_SET_STAR
.
get
(
"edx_video_id"
)}
)
response
=
self
.
client
.
put
(
url
,
dict
(
subtitles
=
[],
encoded_videos
=
[],
**
constants
.
VIDEO_DICT_STAR
),
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# Expect that subtitles have been removed
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
subtitles
.
all
()),
0
)
def
test_update_remove_encoded_videos
(
self
):
# Create some encoded videos
self
.
_create_videos
(
constants
.
COMPLETE_SET_STAR
)
# Sanity check that the encoded videos were created
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
encoded_videos
.
all
()),
1
)
# Update with an empty list of videos
url
=
reverse
(
'video-detail'
,
kwargs
=
{
"edx_video_id"
:
constants
.
COMPLETE_SET_STAR
.
get
(
"edx_video_id"
)}
)
response
=
self
.
client
.
put
(
url
,
dict
(
encoded_videos
=
[],
**
constants
.
VIDEO_DICT_STAR
),
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# Expect that encoded videos have been removed
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
encoded_videos
.
all
()),
0
)
def
test_update_courses
(
self
):
# Create the video with associated course keys
self
.
_create_videos
(
constants
.
COMPLETE_SET_WITH_COURSE_KEY
)
# Verify that the video was associated with the courses
video
=
Video
.
objects
.
get
()
course_keys
=
[
c
.
course_id
for
c
in
CourseVideo
.
objects
.
filter
(
video
=
video
)]
self
.
assertEqual
(
course_keys
,
constants
.
COMPLETE_SET_WITH_COURSE_KEY
[
"courses"
])
# Update the video to associate it with other courses
url
=
reverse
(
'video-detail'
,
kwargs
=
{
"edx_video_id"
:
video
.
edx_video_id
})
response
=
self
.
client
.
put
(
url
,
constants
.
COMPLETE_SET_WITH_OTHER_COURSE_KEYS
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
,
msg
=
response
.
content
)
# Verify that the video's courses were updated
# Note: the current version of edx-val does NOT remove old course videos!
course_keys
=
[
c
.
course_id
for
c
in
CourseVideo
.
objects
.
filter
(
video
=
video
)]
expected_course_keys
=
(
constants
.
COMPLETE_SET_WITH_COURSE_KEY
[
"courses"
]
+
constants
.
COMPLETE_SET_WITH_OTHER_COURSE_KEYS
[
"courses"
]
)
self
.
assertEqual
(
course_keys
,
expected_course_keys
)
def
test_update_invalid_video
(
self
):
def
test_update_invalid_video
(
self
):
"""
"""
Tests PUTting a video with different edx_video_id.
Tests PUTting a video with different edx_video_id.
...
@@ -312,6 +392,14 @@ class VideoDetail(APIAuthTestCase):
...
@@ -312,6 +392,14 @@ class VideoDetail(APIAuthTestCase):
constants
.
ENCODED_VIDEO_DICT_FISH_DESKTOP
.
get
(
"url"
)
constants
.
ENCODED_VIDEO_DICT_FISH_DESKTOP
.
get
(
"url"
)
)
)
def
_create_videos
(
self
,
data
):
"""
Create videos for use in tests.
"""
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
data
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
class
VideoListTest
(
APIAuthTestCase
):
class
VideoListTest
(
APIAuthTestCase
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment