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
afb311ff
Commit
afb311ff
authored
Jul 07, 2014
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user handling bug in split test module
STUD-1948
parent
5f11aa9a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
13 deletions
+50
-13
cms/djangoapps/contentstore/views/preview.py
+16
-0
common/lib/xmodule/xmodule/split_test_module.py
+3
-1
common/test/acceptance/pages/xblock/acid.py
+3
-7
common/test/acceptance/pages/xblock/utils.py
+17
-0
common/test/acceptance/tests/test_studio_split_test.py
+11
-5
No files found.
cms/djangoapps/contentstore/views/preview.py
View file @
afb311ff
...
@@ -95,6 +95,20 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method
...
@@ -95,6 +95,20 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method
return
local_resource_url
(
block
,
uri
)
return
local_resource_url
(
block
,
uri
)
class
StudioUserService
(
object
):
"""
Provides a Studio implementation of the XBlock user service.
"""
def
__init__
(
self
,
request
):
super
(
StudioUserService
,
self
)
.
__init__
()
self
.
_request
=
request
@property
def
user_id
(
self
):
return
self
.
_request
.
user
.
id
def
_preview_module_system
(
request
,
descriptor
):
def
_preview_module_system
(
request
,
descriptor
):
"""
"""
Returns a ModuleSystem for the specified descriptor that is specialized for
Returns a ModuleSystem for the specified descriptor that is specialized for
...
@@ -117,6 +131,8 @@ def _preview_module_system(request, descriptor):
...
@@ -117,6 +131,8 @@ def _preview_module_system(request, descriptor):
_studio_wrap_xblock
,
_studio_wrap_xblock
,
]
]
descriptor
.
runtime
.
_services
[
'user'
]
=
StudioUserService
(
request
)
# pylint: disable=protected-access
return
PreviewModuleSystem
(
return
PreviewModuleSystem
(
static_url
=
settings
.
STATIC_URL
,
static_url
=
settings
.
STATIC_URL
,
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
...
...
common/lib/xmodule/xmodule/split_test_module.py
View file @
afb311ff
...
@@ -343,6 +343,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule):
...
@@ -343,6 +343,7 @@ class SplitTestModule(SplitTestFields, XModule, StudioEditableModule):
@XBlock.needs
(
'user_tags'
)
# pylint: disable=abstract-method
@XBlock.needs
(
'user_tags'
)
# pylint: disable=abstract-method
@XBlock.wants
(
'partitions'
)
@XBlock.wants
(
'partitions'
)
@XBlock.wants
(
'user'
)
class
SplitTestDescriptor
(
SplitTestFields
,
SequenceDescriptor
,
StudioEditableDescriptor
):
class
SplitTestDescriptor
(
SplitTestFields
,
SequenceDescriptor
,
StudioEditableDescriptor
):
# the editing interface can be the same as for sequences -- just a container
# the editing interface can be the same as for sequences -- just a container
module_class
=
SplitTestModule
module_class
=
SplitTestModule
...
@@ -553,7 +554,8 @@ class SplitTestDescriptor(SplitTestFields, SequenceDescriptor, StudioEditableDes
...
@@ -553,7 +554,8 @@ class SplitTestDescriptor(SplitTestFields, SequenceDescriptor, StudioEditableDes
for
group
in
user_partition
.
groups
:
for
group
in
user_partition
.
groups
:
str_group_id
=
unicode
(
group
.
id
)
str_group_id
=
unicode
(
group
.
id
)
if
str_group_id
not
in
self
.
group_id_to_child
:
if
str_group_id
not
in
self
.
group_id_to_child
:
self
.
_create_vertical_for_group
(
group
,
request
.
user
.
id
)
user_id
=
self
.
runtime
.
service
(
self
,
'user'
)
.
user_id
self
.
_create_vertical_for_group
(
group
,
user_id
)
changed
=
True
changed
=
True
if
changed
:
if
changed
:
...
...
common/test/acceptance/pages/xblock/acid.py
View file @
afb311ff
...
@@ -3,7 +3,8 @@ PageObjects related to the AcidBlock
...
@@ -3,7 +3,8 @@ PageObjects related to the AcidBlock
"""
"""
from
bok_choy.page_object
import
PageObject
from
bok_choy.page_object
import
PageObject
from
bok_choy.promise
import
EmptyPromise
,
BrokenPromise
,
Promise
from
bok_choy.promise
import
Promise
from
.utils
import
wait_for_xblock_initialization
class
AcidView
(
PageObject
):
class
AcidView
(
PageObject
):
"""
"""
...
@@ -25,16 +26,11 @@ class AcidView(PageObject):
...
@@ -25,16 +26,11 @@ class AcidView(PageObject):
def
is_browser_on_page
(
self
):
def
is_browser_on_page
(
self
):
def
_is_finished_loading
():
# Wait for the xblock javascript to finish initializing
is_done
=
self
.
browser
.
execute_script
(
"return $({!r}).data('initialized')"
.
format
(
self
.
context_selector
))
return
(
is_done
,
is_done
)
# First make sure that an element with the view-container class is present on the page,
# First make sure that an element with the view-container class is present on the page,
# and then wait to make sure that the xblock has finished initializing.
# and then wait to make sure that the xblock has finished initializing.
return
(
return
(
self
.
q
(
css
=
'{} .acid-block'
.
format
(
self
.
context_selector
))
.
present
and
self
.
q
(
css
=
'{} .acid-block'
.
format
(
self
.
context_selector
))
.
present
and
Promise
(
_is_finished_loading
,
'Finished initializing the xblock.'
)
.
fulfill
(
)
wait_for_xblock_initialization
(
self
,
self
.
context_selector
)
)
)
def
test_passed
(
self
,
test_selector
):
def
test_passed
(
self
,
test_selector
):
...
...
common/test/acceptance/pages/xblock/utils.py
0 → 100644
View file @
afb311ff
"""
Utility methods useful for XBlock page tests.
"""
from
bok_choy.promise
import
Promise
from
selenium.webdriver.common.action_chains
import
ActionChains
def
wait_for_xblock_initialization
(
page
,
xblock_css
):
"""
Wait for the xblock with the given CSS to finish initializing.
"""
def
_is_finished_loading
():
# Wait for the xblock javascript to finish initializing
is_done
=
page
.
browser
.
execute_script
(
"return $({!r}).data('initialized')"
.
format
(
xblock_css
))
return
(
is_done
,
is_done
)
return
Promise
(
_is_finished_loading
,
'Finished initializing the xblock.'
)
.
fulfill
()
common/test/acceptance/tests/test_studio_split_test.py
View file @
afb311ff
...
@@ -6,19 +6,20 @@ import json
...
@@ -6,19 +6,20 @@ import json
import
os
import
os
from
unittest
import
skip
,
skipUnless
from
unittest
import
skip
,
skipUnless
from
..fixtures.course
import
CourseFixture
,
XBlockFixtureDesc
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
bok_choy.promise
import
Promise
from
..fixtures.course
import
CourseFixture
,
XBlockFixtureDesc
from
..pages.studio.component_editor
import
ComponentEditorView
from
..pages.studio.component_editor
import
ComponentEditorView
from
..pages.studio.settings_advanced
import
AdvancedSettingsPage
from
..pages.studio.settings_advanced
import
AdvancedSettingsPage
from
..pages.studio.settings_group_configurations
import
GroupConfigurationsPage
from
..pages.studio.settings_group_configurations
import
GroupConfigurationsPage
from
..pages.studio.auto_auth
import
AutoAuthPage
from
..pages.studio.auto_auth
import
AutoAuthPage
from
test_studio_container
import
ContainerBase
from
..pages.studio.utils
import
add_advanced_component
from
..pages.studio.utils
import
add_advanced_component
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
..pages.xblock.utils
import
wait_for_xblock_initialization
from
bok_choy.promise
import
Promise
from
.helpers
import
UniqueCourseTest
from
.helpers
import
UniqueCourseTest
from
test_studio_container
import
ContainerBase
class
SplitTest
(
ContainerBase
):
class
SplitTest
(
ContainerBase
):
"""
"""
...
@@ -147,6 +148,11 @@ class SplitTest(ContainerBase):
...
@@ -147,6 +148,11 @@ class SplitTest(ContainerBase):
The case of a split test with invalid configuration (missing group).
The case of a split test with invalid configuration (missing group).
"""
"""
container
=
self
.
create_poorly_configured_split_instance
()
container
=
self
.
create_poorly_configured_split_instance
()
# Wait for the xblock to be fully initialized so that the add button is rendered
wait_for_xblock_initialization
(
self
,
'.xblock[data-block-type="split_test"]'
)
# Click the add button and verify that the groups were added on the page
container
.
add_missing_groups
()
container
.
add_missing_groups
()
self
.
verify_groups
(
container
,
[
'alpha'
,
'gamma'
],
[
'beta'
])
self
.
verify_groups
(
container
,
[
'alpha'
,
'gamma'
],
[
'beta'
])
...
...
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