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
16f89dda
Commit
16f89dda
authored
8 years ago
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support force update param in generate_course_blocks Management Command
parent
01fca6b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
lms/djangoapps/course_blocks/management/commands/generate_course_blocks.py
+11
-2
lms/djangoapps/course_blocks/management/commands/tests/test_generate_course_blocks.py
+15
-0
No files found.
lms/djangoapps/course_blocks/management/commands/generate_course_blocks.py
View file @
16f89dda
...
...
@@ -8,7 +8,7 @@ from opaque_keys import InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
xmodule.modulestore.django
import
modulestore
from
...api
import
get_course_in_cache
from
...api
import
get_course_in_cache
,
update_course_in_cache
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -39,6 +39,12 @@ class Command(BaseCommand):
action
=
'store_true'
,
default
=
False
,
)
parser
.
add_argument
(
'--force'
,
help
=
'Force update of the course blocks for the requested courses.'
,
action
=
'store_true'
,
default
=
False
,
)
def
handle
(
self
,
*
args
,
**
options
):
...
...
@@ -57,7 +63,10 @@ class Command(BaseCommand):
for
course_key
in
course_keys
:
try
:
block_structure
=
get_course_in_cache
(
course_key
)
if
options
.
get
(
'force'
):
block_structure
=
update_course_in_cache
(
course_key
)
else
:
block_structure
=
get_course_in_cache
(
course_key
)
if
options
.
get
(
'dags'
):
self
.
_find_and_log_dags
(
block_structure
,
course_key
)
except
Exception
as
ex
:
# pylint: disable=broad-except
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/course_blocks/management/commands/tests/test_generate_course_blocks.py
View file @
16f89dda
...
...
@@ -44,6 +44,21 @@ class TestGenerateCourseBlocks(ModuleStoreTestCase):
self
.
_assert_courses_not_in_block_cache
(
self
.
course_1
.
id
,
self
.
course_2
.
id
)
self
.
command
.
handle
(
all
=
True
)
self
.
_assert_courses_in_block_cache
(
self
.
course_1
.
id
,
self
.
course_2
.
id
)
with
patch
(
'openedx.core.lib.block_structure.factory.BlockStructureFactory.create_from_modulestore'
)
as
mock_update_from_store
:
self
.
command
.
handle
(
all
=
True
)
mock_update_from_store
.
assert_not_called
()
def
test_generate_force
(
self
):
self
.
_assert_courses_not_in_block_cache
(
self
.
course_1
.
id
,
self
.
course_2
.
id
)
self
.
command
.
handle
(
all
=
True
)
self
.
_assert_courses_in_block_cache
(
self
.
course_1
.
id
,
self
.
course_2
.
id
)
with
patch
(
'openedx.core.lib.block_structure.factory.BlockStructureFactory.create_from_modulestore'
)
as
mock_update_from_store
:
self
.
command
.
handle
(
all
=
True
,
force
=
True
)
mock_update_from_store
.
assert_called
()
def
test_generate_one
(
self
):
self
.
_assert_courses_not_in_block_cache
(
self
.
course_1
.
id
,
self
.
course_2
.
id
)
...
...
This diff is collapsed.
Click to expand it.
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