Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e592eef0
Commit
e592eef0
authored
10 years ago
by
Christopher Lee
Browse files
Options
Downloads
Plain Diff
Merge pull request #6675 from edx/clee-MA-234-hotfix
Named_path variable now populates complete path
parents
62495847
b6c08ad2
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/mobile_api/video_outlines/serializers.py
+1
-1
1 addition, 1 deletion
lms/djangoapps/mobile_api/video_outlines/serializers.py
lms/djangoapps/mobile_api/video_outlines/tests.py
+173
-25
173 additions, 25 deletions
lms/djangoapps/mobile_api/video_outlines/tests.py
with
174 additions
and
26 deletions
lms/djangoapps/mobile_api/video_outlines/serializers.py
+
1
−
1
View file @
e592eef0
...
...
@@ -153,7 +153,7 @@ class BlockOutline(object):
yield
{
"
path
"
:
block_path
,
"
named_path
"
:
[
b
[
"
name
"
]
for
b
in
block_path
[:
-
1
]
],
"
named_path
"
:
[
b
[
"
name
"
]
for
b
in
block_path
],
"
unit_url
"
:
unit_url
,
"
section_url
"
:
section_url
,
"
summary
"
:
summary_fn
(
self
.
course_id
,
curr_block
,
self
.
request
,
self
.
local_cache
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/mobile_api/video_outlines/tests.py
+
173
−
25
View file @
e592eef0
...
...
@@ -128,15 +128,62 @@ class TestVideoAPITestCase(MobileAPITestCase):
)
class
Test
EmptyCourseVideoSummaryList
(
MobileAPITestCase
):
class
Test
NonStandardCourseStructure
(
MobileAPITestCase
):
"""
Tests /api/mobile/v0.5/video_outlines/courses/{course_id} with no course set
"""
REVERSE_INFO
=
{
'
name
'
:
'
video-summary-list
'
,
'
params
'
:
[
'
course_id
'
]}
def
test_chapter_is_none
(
self
):
def
_verify_paths
(
self
,
course_outline
,
path_list
):
"""
Tests when there is no chapter under course, and video under course
Takes a path_list and compares it against the course_outline
Attributes:
path_list (list): A list of the expected strings
course_outline (list): A list of dictionaries that includes a
'
path
'
and
'
named_path
'
field which we will be comparing path_list to
"""
path
=
course_outline
[
0
][
'
path
'
]
self
.
assertEqual
(
len
(
path
),
len
(
path_list
))
for
i
in
range
(
0
,
len
(
path_list
)):
self
.
assertEqual
(
path_list
[
i
],
path
[
i
][
'
name
'
])
#named_path will be deprecated eventually
named_path
=
course_outline
[
0
][
'
named_path
'
]
self
.
assertEqual
(
len
(
named_path
),
len
(
path_list
))
for
i
in
range
(
0
,
len
(
path_list
)):
self
.
assertEqual
(
path_list
[
i
],
named_path
[
i
])
def
setUp
(
self
):
super
(
TestNonStandardCourseStructure
,
self
).
setUp
()
self
.
chapter_under_course
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
category
=
"
chapter
"
,
display_name
=
u
"
test factory chapter under course omega
\u03a9
"
,
)
self
.
section_under_course
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
category
=
"
sequential
"
,
display_name
=
u
"
test factory section under course omega
\u03a9
"
,
)
self
.
section_under_chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
chapter_under_course
.
location
,
category
=
"
sequential
"
,
display_name
=
u
"
test factory section under chapter omega
\u03a9
"
,
)
self
.
vertical_under_course
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
category
=
"
vertical
"
,
display_name
=
u
"
test factory vertical under course omega
\u03a9
"
,
)
self
.
vertical_under_section
=
ItemFactory
.
create
(
parent_location
=
self
.
section_under_chapter
.
location
,
category
=
"
vertical
"
,
display_name
=
u
"
test factory vertical under section omega
\u03a9
"
,
)
def
test_structure_course_video
(
self
):
"""
Tests when there is a video without a vertical directly under course
"""
self
.
login_and_enroll
()
ItemFactory
.
create
(
...
...
@@ -149,22 +196,45 @@ class TestEmptyCourseVideoSummaryList(MobileAPITestCase):
section_url
=
course_outline
[
0
][
"
section_url
"
]
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
r
'
courseware$
'
)
self
.
assertTrue
(
section_url
)
self
.
assertTrue
(
unit_url
)
self
.
assertEqual
(
section_url
,
unit_url
)
def
test_section_is_none
(
self
):
self
.
_verify_paths
(
course_outline
,
[])
def
test_structure_course_vert_video
(
self
):
"""
Tests when there is
no section under chapter, and video
under c
hapter
Tests when there is
a video under vertical directly
under c
ourse
"""
self
.
login_and_enroll
()
self
.
chapter
=
ItemFactory
.
create
(
# pylint:disable=W0201
parent_location
=
self
.
course
.
location
,
category
=
"
chapter
"
,
display_name
=
u
"
test factory chapter omega
\u03a9
"
,
ItemFactory
.
create
(
parent_location
=
self
.
vertical_under_course
.
location
,
category
=
"
video
"
,
display_name
=
u
"
test factory video omega
\u03a9
"
,
)
course_outline
=
self
.
api_response
().
data
self
.
assertEqual
(
len
(
course_outline
),
1
)
section_url
=
course_outline
[
0
][
"
section_url
"
]
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
r
'
courseware/test_factory_vertical_under_course_omega_%CE%A9/$
'
)
self
.
assertEqual
(
section_url
,
unit_url
)
self
.
_verify_paths
(
course_outline
,
[
u
'
test factory vertical under course omega
\u03a9
'
]
)
def
test_structure_course_chap_video
(
self
):
"""
Tests when there is a video directly under chapter
"""
self
.
login_and_enroll
()
ItemFactory
.
create
(
parent_location
=
self
.
chapter
.
location
,
parent_location
=
self
.
chapter
_under_course
.
location
,
category
=
"
video
"
,
display_name
=
u
"
test factory video omega
\u03a9
"
,
)
...
...
@@ -174,24 +244,25 @@ class TestEmptyCourseVideoSummaryList(MobileAPITestCase):
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
r
'
courseware/test_factory_chapter_omega_%CE%A9/$
'
r
'
courseware/test_factory_chapter_
under_course_
omega_%CE%A9/$
'
)
self
.
assertTrue
(
section_url
)
self
.
assertTrue
(
unit_url
)
self
.
assertEqual
(
section_url
,
unit_url
)
def
test_section_under_course
(
self
):
self
.
_verify_paths
(
course_outline
,
[
u
'
test factory chapter under course omega
\u03a9
'
,
]
)
def
test_structure_course_section_video
(
self
):
"""
Tests when chapter is none, and video under section under course
"""
self
.
login_and_enroll
()
self
.
section
=
ItemFactory
.
create
(
# pylint:disable=W0201
parent_location
=
self
.
course
.
location
,
category
=
"
sequential
"
,
display_name
=
u
"
test factory section omega
\u03a9
"
,
)
ItemFactory
.
create
(
parent_location
=
self
.
section
.
location
,
parent_location
=
self
.
section
_under_course
.
location
,
category
=
"
video
"
,
display_name
=
u
"
test factory video omega
\u03a9
"
,
)
...
...
@@ -201,12 +272,89 @@ class TestEmptyCourseVideoSummaryList(MobileAPITestCase):
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
r
'
courseware/test_factory_section_omega_%CE%A9/$
'
r
'
courseware/test_factory_section_
under_course_
omega_%CE%A9/$
'
)
self
.
assertTrue
(
section_url
)
self
.
assertTrue
(
unit_url
)
self
.
assertEqual
(
section_url
,
unit_url
)
self
.
_verify_paths
(
course_outline
,
[
u
'
test factory section under course omega
\u03a9
'
,
]
)
def
test_structure_course_chap_section_video
(
self
):
"""
Tests when chapter and sequential exists, with a video with no vertical.
"""
self
.
login_and_enroll
()
ItemFactory
.
create
(
parent_location
=
self
.
section_under_chapter
.
location
,
category
=
"
video
"
,
display_name
=
u
"
meow factory video omega
\u03a9
"
,
)
course_outline
=
self
.
api_response
().
data
self
.
assertEqual
(
len
(
course_outline
),
1
)
section_url
=
course_outline
[
0
][
"
section_url
"
]
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
(
r
'
courseware/test_factory_chapter_under_course_omega_%CE%A9/
'
+
'
test_factory_section_under_chapter_omega_%CE%A9/$
'
)
)
self
.
assertEqual
(
section_url
,
unit_url
)
self
.
_verify_paths
(
course_outline
,
[
u
'
test factory chapter under course omega
\u03a9
'
,
u
'
test factory section under chapter omega
\u03a9
'
,
]
)
def
test_structure_course_section_vert_video
(
self
):
"""
Tests chapter->section->vertical->unit
"""
self
.
login_and_enroll
()
ItemFactory
.
create
(
parent_location
=
self
.
vertical_under_section
.
location
,
category
=
"
video
"
,
display_name
=
u
"
test factory video omega
\u03a9
"
,
)
course_outline
=
self
.
api_response
().
data
self
.
assertEqual
(
len
(
course_outline
),
1
)
section_url
=
course_outline
[
0
][
"
section_url
"
]
unit_url
=
course_outline
[
0
][
"
unit_url
"
]
self
.
assertRegexpMatches
(
section_url
,
(
r
'
courseware/test_factory_chapter_under_course_omega_%CE%A9/
'
+
'
test_factory_section_under_chapter_omega_%CE%A9/$
'
)
)
self
.
assertRegexpMatches
(
unit_url
,
(
r
'
courseware/test_factory_chapter_under_course_omega_%CE%A9/
'
+
'
test_factory_section_under_chapter_omega_%CE%A9/1$
'
)
)
self
.
_verify_paths
(
course_outline
,
[
u
'
test factory chapter under course omega
\u03a9
'
,
u
'
test factory section under chapter omega
\u03a9
'
,
u
'
test factory vertical under section omega
\u03a9
'
]
)
class
TestVideoSummaryList
(
TestVideoAPITestCase
,
MobileAuthTestMixin
,
MobileEnrolledCourseAccessTestMixin
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment