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
152ae4b1
Commit
152ae4b1
authored
Jul 26, 2016
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix xblock urls for verticals
TNL-5003
parent
df66a8e3
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 @
152ae4b1
...
@@ -5,6 +5,8 @@ Utility methods for unit tests.
...
@@ -5,6 +5,8 @@ Utility methods for unit tests.
import
filecmp
import
filecmp
from
path
import
Path
as
path
from
path
import
Path
as
path
from
xblock.reference.user_service
import
XBlockUser
,
UserService
def
directories_equal
(
directory1
,
directory2
):
def
directories_equal
(
directory1
,
directory2
):
"""
"""
...
@@ -24,3 +26,16 @@ def directories_equal(directory1, directory2):
...
@@ -24,3 +26,16 @@ def directories_equal(directory1, directory2):
return
True
return
True
return
compare_dirs
(
path
(
directory1
),
path
(
directory2
))
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 @
152ae4b1
...
@@ -7,27 +7,14 @@ import ddt
...
@@ -7,27 +7,14 @@ import ddt
from
django.utils.timezone
import
now
from
django.utils.timezone
import
now
from
freezegun
import
freeze_time
from
freezegun
import
freeze_time
from
mock
import
Mock
from
mock
import
Mock
from
xblock.reference.user_service
import
XBlockUser
,
UserService
from
xmodule.tests
import
get_test_system
from
xmodule.tests
import
get_test_system
from
xmodule.tests.helpers
import
StubUserService
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.x_module
import
STUDENT_VIEW
from
xmodule.x_module
import
STUDENT_VIEW
from
xmodule.seq_module
import
SequenceModule
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
@ddt.ddt
class
SequenceBlockTestCase
(
XModuleXmlImportTest
):
class
SequenceBlockTestCase
(
XModuleXmlImportTest
):
"""
"""
...
...
common/lib/xmodule/xmodule/tests/test_vertical.py
View file @
152ae4b1
"""
"""
Tests for vertical module.
Tests for vertical module.
"""
"""
import
ddt
from
mock
import
Mock
from
fs.memoryfs
import
MemoryFS
from
fs.memoryfs
import
MemoryFS
from
xmodule.tests
import
get_test_system
from
xmodule.tests
import
get_test_system
from
xmodule.tests.helpers
import
StubUserService
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.x_module
import
STUDENT_VIEW
,
AUTHOR_VIEW
from
xmodule.x_module
import
STUDENT_VIEW
,
AUTHOR_VIEW
...
@@ -41,6 +43,7 @@ class BaseVerticalBlockTest(XModuleXmlImportTest):
...
@@ -41,6 +43,7 @@ class BaseVerticalBlockTest(XModuleXmlImportTest):
self
.
default_context
=
{
"bookmarked"
:
False
,
"username"
:
self
.
username
}
self
.
default_context
=
{
"bookmarked"
:
False
,
"username"
:
self
.
username
}
@ddt.ddt
class
VerticalBlockTestCase
(
BaseVerticalBlockTest
):
class
VerticalBlockTestCase
(
BaseVerticalBlockTest
):
"""
"""
Tests for the VerticalBlock.
Tests for the VerticalBlock.
...
@@ -54,11 +57,21 @@ class VerticalBlockTestCase(BaseVerticalBlockTest):
...
@@ -54,11 +57,21 @@ class VerticalBlockTestCase(BaseVerticalBlockTest):
self
.
assertIn
(
'bookmarked'
,
content
)
self
.
assertIn
(
'bookmarked'
,
content
)
self
.
assertIn
(
'show_bookmark_button'
,
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.
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_1
,
html
)
self
.
assertIn
(
self
.
test_html_2
,
html
)
self
.
assertIn
(
self
.
test_html_2
,
html
)
self
.
assert_bookmark_info_in
(
html
)
self
.
assert_bookmark_info_in
(
html
)
...
...
common/lib/xmodule/xmodule/vertical_block.py
View file @
152ae4b1
...
@@ -20,6 +20,7 @@ log = logging.getLogger(__name__)
...
@@ -20,6 +20,7 @@ log = logging.getLogger(__name__)
CLASS_PRIORITY
=
[
'video'
,
'problem'
]
CLASS_PRIORITY
=
[
'video'
,
'problem'
]
@XBlock.needs
(
'user'
,
'bookmarks'
)
class
VerticalBlock
(
SequenceFields
,
XModuleFields
,
StudioEditableBlock
,
XmlParserMixin
,
MakoTemplateBlockBase
,
XBlock
):
class
VerticalBlock
(
SequenceFields
,
XModuleFields
,
StudioEditableBlock
,
XmlParserMixin
,
MakoTemplateBlockBase
,
XBlock
):
"""
"""
Layout XBlock for rendering subblocks vertically.
Layout XBlock for rendering subblocks vertically.
...
@@ -41,7 +42,14 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
...
@@ -41,7 +42,14 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
fragment
=
Fragment
()
fragment
=
Fragment
()
contents
=
[]
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
child_context
[
'child_of_vertical'
]
=
True
# pylint: disable=no-member
# 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