Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
61ba9102
Commit
61ba9102
authored
10 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Add a test of pure xblock and xmodule event publishing
parent
368dbf2e
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lms/djangoapps/courseware/tests/test_module_render.py
+49
-1
49 additions, 1 deletion
lms/djangoapps/courseware/tests/test_module_render.py
with
49 additions
and
1 deletion
lms/djangoapps/courseware/tests/test_module_render.py
+
49
−
1
View file @
61ba9102
...
...
@@ -39,7 +39,7 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
,
check_mongo_calls
from
xmodule.x_module
import
XModuleDescriptor
,
STUDENT_VIEW
from
xmodule.x_module
import
XModuleDescriptor
,
XModule
,
STUDENT_VIEW
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
...
...
@@ -51,6 +51,14 @@ class PureXBlock(XBlock):
pass
class
EmptyXModule
(
XModule
):
pass
class
EmptyXModuleDescriptor
(
XModuleDescriptor
):
module_class
=
EmptyXModule
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
ModuleRenderTestCase
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
...
...
@@ -1105,3 +1113,43 @@ class TestRebindModule(TestSubmittingProblems):
module
=
self
.
get_module_for_user
(
self
.
anon_user
)
module
.
system
.
rebind_noauth_module_to_user
(
module
,
self
.
anon_user
)
self
.
assertFalse
(
psycho_handler
.
called
)
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
TestEventPublishing
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
def
setUp
(
self
):
"""
Set up the course and user context
"""
super
(
TestEventPublishing
,
self
).
setUp
()
self
.
mock_user
=
UserFactory
()
self
.
mock_user
.
id
=
1
self
.
request_factory
=
RequestFactory
()
@ddt.data
(
'
xblock
'
,
'
xmodule
'
)
@XBlock.register_temp_plugin
(
PureXBlock
,
identifier
=
'
xblock
'
)
@XBlock.register_temp_plugin
(
EmptyXModuleDescriptor
,
identifier
=
'
xmodule
'
)
@patch.object
(
render
,
'
make_track_function
'
)
def
test_event_publishing
(
self
,
block_type
,
mock_track_function
):
request
=
self
.
request_factory
.
get
(
''
)
request
.
user
=
self
.
mock_user
course
=
CourseFactory
()
descriptor
=
ItemFactory
(
category
=
block_type
,
parent
=
course
)
field_data_cache
=
FieldDataCache
([
course
,
descriptor
],
course
.
id
,
self
.
mock_user
)
block
=
render
.
get_module
(
self
.
mock_user
,
request
,
descriptor
.
location
,
field_data_cache
)
event_type
=
'
event_type
'
event
=
{
'
event
'
:
'
data
'
}
block
.
runtime
.
publish
(
block
,
event_type
,
event
)
mock_track_function
.
assert_called_once_with
(
request
)
if
block_type
==
'
xblock
'
:
self
.
assertFalse
(
mock_track_function
.
return_value
.
called
)
else
:
mock_track_function
.
return_value
.
assert_called_once_with
(
event_type
,
event
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment