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
23baab6b
Commit
23baab6b
authored
Jan 08, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test to exercise library root paged rendering
parent
5342fa27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py
+38
-0
No files found.
common/lib/xmodule/xmodule/modulestore/tests/test_libraries.py
View file @
23baab6b
...
...
@@ -207,6 +207,44 @@ class TestLibraries(MixedSplitTestCase):
result
=
library
.
render
(
AUTHOR_VIEW
,
context
)
self
.
assertIn
(
message
,
result
.
content
)
@patch
(
'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render'
,
VanillaRuntime
.
render
)
def
test_library_author_view_with_paging
(
self
):
"""
Test that LibraryRoot.author_view can apply paging
We have to patch the runtime (module system) in order to be able to
render blocks in our test environment.
"""
library
=
LibraryFactory
.
create
(
modulestore
=
self
.
store
)
# Add five HTML blocks to the library:
blocks
=
[
ItemFactory
.
create
(
category
=
"html"
,
parent_location
=
library
.
location
,
user_id
=
self
.
user_id
,
publish_item
=
False
,
modulestore
=
self
.
store
,
data
=
"HtmlBlock"
+
str
(
i
)
)
for
i
in
range
(
5
)
]
library
=
self
.
store
.
get_library
(
library
.
location
.
library_key
)
def
render_and_check_contents
(
page
,
page_size
):
context
=
{
'reorderable_items'
:
set
(),
'paging'
:
{
'page_number'
:
page
,
'page_size'
:
page_size
}}
expected_blocks
=
blocks
[
page_size
*
page
:
page_size
*
(
page
+
1
)]
result
=
library
.
render
(
AUTHOR_VIEW
,
context
)
for
expected_block
in
expected_blocks
:
self
.
assertIn
(
expected_block
.
data
,
result
.
content
)
hello_render
=
lambda
block
,
_
:
Fragment
(
block
.
data
)
with
patch
(
'xmodule.html_module.HtmlDescriptor.author_view'
,
hello_render
,
create
=
True
):
with
patch
(
'xmodule.x_module.DescriptorSystem.applicable_aside_types'
,
lambda
self
,
block
:
[]):
render_and_check_contents
(
0
,
3
)
render_and_check_contents
(
1
,
3
)
render_and_check_contents
(
0
,
2
)
render_and_check_contents
(
1
,
2
)
def
test_xblock_in_lib_have_published_version_returns_false
(
self
):
library
=
LibraryFactory
.
create
(
modulestore
=
self
.
store
)
block
=
ItemFactory
.
create
(
...
...
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