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
113458a3
Commit
113458a3
authored
Jul 27, 2016
by
Muhammad Ammar
Committed by
GitHub
Jul 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13100 from edx/ammar/tnl-5003-fix-xblock-url-for-verticals
fix xblock urls for verticals
parents
df66a8e3
152ae4b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
18 deletions
+41
-18
common/lib/xmodule/xmodule/tests/helpers.py
+15
-0
common/lib/xmodule/xmodule/tests/test_sequence.py
+1
-14
common/lib/xmodule/xmodule/tests/test_vertical.py
+16
-3
common/lib/xmodule/xmodule/vertical_block.py
+9
-1
No files found.
common/lib/xmodule/xmodule/tests/helpers.py
View file @
113458a3
...
...
@@ -5,6 +5,8 @@ Utility methods for unit tests.
import
filecmp
from
path
import
Path
as
path
from
xblock.reference.user_service
import
XBlockUser
,
UserService
def
directories_equal
(
directory1
,
directory2
):
"""
...
...
@@ -24,3 +26,16 @@ def directories_equal(directory1, directory2):
return
True
return
compare_dirs
(
path
(
directory1
),
path
(
directory2
))
class
StubUserService
(
UserService
):
"""
Stub UserService for testing the sequence module.
"""
def
get_current_user
(
self
):
"""
Implements abstract method for getting the current user.
"""
user
=
XBlockUser
()
user
.
opt_attrs
[
'edx-platform.username'
]
=
'bilbo'
return
user
common/lib/xmodule/xmodule/tests/test_sequence.py
View file @
113458a3
...
...
@@ -7,27 +7,14 @@ import ddt
from
django.utils.timezone
import
now
from
freezegun
import
freeze_time
from
mock
import
Mock
from
xblock.reference.user_service
import
XBlockUser
,
UserService
from
xmodule.tests
import
get_test_system
from
xmodule.tests.helpers
import
StubUserService
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.x_module
import
STUDENT_VIEW
from
xmodule.seq_module
import
SequenceModule
class
StubUserService
(
UserService
):
"""
Stub UserService for testing the sequence module.
"""
def
get_current_user
(
self
):
"""
Implements abstract method for getting the current user.
"""
user
=
XBlockUser
()
user
.
opt_attrs
[
'edx-platform.username'
]
=
'test user'
return
user
@ddt.ddt
class
SequenceBlockTestCase
(
XModuleXmlImportTest
):
"""
...
...
common/lib/xmodule/xmodule/tests/test_vertical.py
View file @
113458a3
"""
Tests for vertical module.
"""
import
ddt
from
mock
import
Mock
from
fs.memoryfs
import
MemoryFS
from
xmodule.tests
import
get_test_system
from
xmodule.tests.helpers
import
StubUserService
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.x_module
import
STUDENT_VIEW
,
AUTHOR_VIEW
...
...
@@ -41,6 +43,7 @@ class BaseVerticalBlockTest(XModuleXmlImportTest):
self
.
default_context
=
{
"bookmarked"
:
False
,
"username"
:
self
.
username
}
@ddt.ddt
class
VerticalBlockTestCase
(
BaseVerticalBlockTest
):
"""
Tests for the VerticalBlock.
...
...
@@ -54,11 +57,21 @@ class VerticalBlockTestCase(BaseVerticalBlockTest):
self
.
assertIn
(
'bookmarked'
,
content
)
self
.
assertIn
(
'show_bookmark_button'
,
content
)
def
test_render_student_view
(
self
):
@ddt.unpack
@ddt.data
(
{
'context'
:
None
},
{
'context'
:
{}}
)
def
test_render_student_view
(
self
,
context
):
"""
Test the rendering of the student view.
"""
html
=
self
.
module_system
.
render
(
self
.
vertical
,
STUDENT_VIEW
,
self
.
default_context
)
.
content
self
.
module_system
.
_services
[
'bookmarks'
]
=
Mock
()
# pylint: disable=protected-access
self
.
module_system
.
_services
[
'user'
]
=
StubUserService
()
# pylint: disable=protected-access
html
=
self
.
module_system
.
render
(
self
.
vertical
,
STUDENT_VIEW
,
self
.
default_context
if
context
is
None
else
context
)
.
content
self
.
assertIn
(
self
.
test_html_1
,
html
)
self
.
assertIn
(
self
.
test_html_2
,
html
)
self
.
assert_bookmark_info_in
(
html
)
...
...
common/lib/xmodule/xmodule/vertical_block.py
View file @
113458a3
...
...
@@ -20,6 +20,7 @@ log = logging.getLogger(__name__)
CLASS_PRIORITY
=
[
'video'
,
'problem'
]
@XBlock.needs
(
'user'
,
'bookmarks'
)
class
VerticalBlock
(
SequenceFields
,
XModuleFields
,
StudioEditableBlock
,
XmlParserMixin
,
MakoTemplateBlockBase
,
XBlock
):
"""
Layout XBlock for rendering subblocks vertically.
...
...
@@ -41,7 +42,14 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
fragment
=
Fragment
()
contents
=
[]
child_context
=
{}
if
not
context
else
copy
(
context
)
if
context
:
child_context
=
copy
(
context
)
else
:
child_context
=
{
'bookmarked'
:
self
.
runtime
.
service
(
self
,
'bookmarks'
)
.
is_bookmarked
(
usage_key
=
self
.
location
),
# pylint: disable=no-member
'username'
:
self
.
runtime
.
service
(
self
,
'user'
)
.
get_current_user
()
.
opt_attrs
[
'edx-platform.username'
]
}
child_context
[
'child_of_vertical'
]
=
True
# pylint: disable=no-member
...
...
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