Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
f5132903
Commit
f5132903
authored
Jan 08, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for LibraryList
parent
84edced1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
3 deletions
+48
-3
common/lib/xmodule/xmodule/tests/test_library_content.py
+48
-3
No files found.
common/lib/xmodule/xmodule/tests/test_library_content.py
View file @
f5132903
...
@@ -6,12 +6,16 @@ Higher-level tests are in `cms/djangoapps/contentstore/tests/test_libraries.py`.
...
@@ -6,12 +6,16 @@ Higher-level tests are in `cms/djangoapps/contentstore/tests/test_libraries.py`.
"""
"""
import
ddt
import
ddt
from
mock
import
patch
from
mock
import
patch
from
unittest
import
TestCase
from
bson.objectid
import
ObjectId
from
opaque_keys.edx.locator
import
LibraryLocator
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
xblock.runtime
import
Runtime
as
VanillaRuntime
from
xblock.runtime
import
Runtime
as
VanillaRuntime
from
xmodule.x_module
import
AUTHOR_VIEW
,
STUDENT_VIEW
from
xmodule.x_module
import
AUTHOR_VIEW
,
STUDENT_VIEW
from
xmodule.library_content_module
import
LibraryVersionReference
,
ANY_CAPA_TYPE_VALUE
,
LibraryContentDescriptor
from
xmodule.library_content_module
import
LibraryVersionReference
,
LibraryList
,
ANY_CAPA_TYPE_VALUE
,
LibraryContentDescriptor
from
xmodule.modulestore.tests.factories
import
LibraryFactory
,
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
LibraryFactory
,
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.utils
import
MixedSplitTestCase
from
xmodule.modulestore.tests.utils
import
MixedSplitTestCase
from
xmodule.tests
import
get_test_system
from
xmodule.tests
import
get_test_system
...
@@ -290,4 +294,45 @@ class TestLibraryContentRender(BaseTestLibraryContainer):
...
@@ -290,4 +294,45 @@ class TestLibraryContentRender(BaseTestLibraryContainer):
self
.
_bind_course_module
(
self
.
lc_block
)
self
.
_bind_course_module
(
self
.
lc_block
)
rendered
=
self
.
lc_block
.
render
(
AUTHOR_VIEW
,
{})
rendered
=
self
.
lc_block
.
render
(
AUTHOR_VIEW
,
{})
self
.
assertEqual
(
""
,
rendered
.
content
)
# content should be empty
self
.
assertEqual
(
""
,
rendered
.
content
)
# content should be empty
self
.
assertEqual
(
"LibraryContentAuthorView"
,
rendered
.
js_init_fn
)
# but some js initialization should happen
self
.
assertEqual
(
"LibraryContentAuthorView"
,
rendered
.
js_init_fn
)
# but some js initialization should happen
\ No newline at end of file
class
TestLibraryList
(
TestCase
):
""" Tests for LibraryList XBlock Field """
def
test_from_json_runtime_style
(
self
):
"""
Test that LibraryList can parse raw libraries list as passed by runtime
"""
lib_list
=
LibraryList
()
lib1_key
,
lib1_version
=
u'library-v1:Org1+Lib1'
,
'5436ffec56c02c13806a4c1b'
lib2_key
,
lib2_version
=
u'library-v1:Org2+Lib2'
,
'112dbaf312c0daa019ce9992'
raw
=
[[
lib1_key
,
lib1_version
],
[
lib2_key
,
lib2_version
]]
parsed
=
lib_list
.
from_json
(
raw
)
self
.
assertEqual
(
len
(
parsed
),
2
)
self
.
assertEquals
(
parsed
[
0
]
.
library_id
,
LibraryLocator
.
from_string
(
lib1_key
))
self
.
assertEquals
(
parsed
[
0
]
.
version
,
ObjectId
(
lib1_version
))
self
.
assertEquals
(
parsed
[
1
]
.
library_id
,
LibraryLocator
.
from_string
(
lib2_key
))
self
.
assertEquals
(
parsed
[
1
]
.
version
,
ObjectId
(
lib2_version
))
def
test_from_json_studio_editor_style
(
self
):
"""
Test that LibraryList can parse raw libraries list as passed by studio editor
"""
lib_list
=
LibraryList
()
lib1_key
,
lib1_version
=
u'library-v1:Org1+Lib1'
,
'5436ffec56c02c13806a4c1b'
lib2_key
,
lib2_version
=
u'library-v1:Org2+Lib2'
,
'112dbaf312c0daa019ce9992'
raw
=
[
lib1_key
+
','
+
lib1_version
,
lib2_key
+
','
+
lib2_version
]
parsed
=
lib_list
.
from_json
(
raw
)
self
.
assertEqual
(
len
(
parsed
),
2
)
self
.
assertEquals
(
parsed
[
0
]
.
library_id
,
LibraryLocator
.
from_string
(
lib1_key
))
self
.
assertEquals
(
parsed
[
0
]
.
version
,
ObjectId
(
lib1_version
))
self
.
assertEquals
(
parsed
[
1
]
.
library_id
,
LibraryLocator
.
from_string
(
lib2_key
))
self
.
assertEquals
(
parsed
[
1
]
.
version
,
ObjectId
(
lib2_version
))
def
test_from_json_invalid_value
(
self
):
"""
Test that LibraryList raises Value error if invalid library key is given
"""
lib_list
=
LibraryList
()
with
self
.
assertRaises
(
ValueError
):
lib_list
.
from_json
([
"Not-a-library-key,whatever"
])
\ No newline at end of file
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