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
041a3df9
Commit
041a3df9
authored
Feb 24, 2017
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
short circuit on library publish; for TNL-6297
parent
ae1853bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
openedx/core/djangoapps/content/block_structure/signals.py
+6
-0
openedx/core/djangoapps/content/block_structure/tests/test_signals.py
+12
-0
No files found.
openedx/core/djangoapps/content/block_structure/signals.py
View file @
041a3df9
...
...
@@ -6,6 +6,8 @@ from django.dispatch.dispatcher import receiver
from
xmodule.modulestore.django
import
SignalHandler
from
opaque_keys.edx.locator
import
LibraryLocator
from
.
import
config
from
.api
import
clear_course_from_cache
from
.tasks
import
update_course_in_cache
...
...
@@ -16,7 +18,11 @@ def _listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable
"""
Catches the signal that a course has been published in the module
store and creates/updates the corresponding cache entry.
Ignores publish signals from content libraries.
"""
if
isinstance
(
course_key
,
LibraryLocator
):
return
if
config
.
is_enabled
(
config
.
INVALIDATE_CACHE_ON_PUBLISH
):
clear_course_from_cache
(
course_key
)
...
...
openedx/core/djangoapps/content/block_structure/tests/test_signals.py
View file @
041a3df9
...
...
@@ -5,11 +5,13 @@ import ddt
from
mock
import
patch
from
waffle.testutils
import
override_switch
from
opaque_keys.edx.locator
import
LibraryLocator
,
CourseLocator
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
..api
import
get_block_structure_manager
from
..signals
import
_listen_for_course_publish
from
..config
import
INVALIDATE_CACHE_ON_PUBLISH
,
waffle_switch_name
from
.helpers
import
is_course_in_block_structure_cache
...
...
@@ -69,3 +71,13 @@ class CourseBlocksSignalTest(ModuleStoreTestCase):
bs_manager
.
get_collected
()
self
.
assertFalse
(
is_course_in_block_structure_cache
(
self
.
course
.
id
,
self
.
store
))
@ddt.data
(
(
CourseLocator
(
org
=
'org'
,
course
=
'course'
,
run
=
'run'
),
True
),
(
LibraryLocator
(
org
=
'org'
,
course
=
'course'
),
False
),
)
@ddt.unpack
@patch
(
'openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache.apply_async'
)
def
test_update_only_for_courses
(
self
,
key
,
expect_update_called
,
mock_update
):
_listen_for_course_publish
(
sender
=
None
,
course_key
=
key
)
self
.
assertEqual
(
mock_update
.
called
,
expect_update_called
)
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