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
956a960c
Commit
956a960c
authored
Aug 08, 2013
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command to dump the course_ids available to the LMS
parent
15852cd8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
lms/djangoapps/courseware/management/commands/dump_course_ids.py
+36
-0
lms/djangoapps/courseware/tests/test_commands.py
+45
-0
No files found.
lms/djangoapps/courseware/management/commands/dump_course_ids.py
0 → 100644
View file @
956a960c
# pylint: disable=missing-docstring
from
optparse
import
make_option
from
textwrap
import
dedent
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xmodule.modulestore.django
import
modulestore
class
Command
(
BaseCommand
):
"""
Simple command to dump the course_ids available to the lms.
"""
help
=
dedent
(
__doc__
)
.
strip
()
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--modulestore'
,
action
=
'store'
,
default
=
'default'
,
help
=
'Name of the modulestore to use'
),
)
def
handle
(
self
,
*
args
,
**
options
):
output
=
[]
try
:
name
=
options
[
'modulestore'
]
store
=
modulestore
(
name
)
except
KeyError
:
raise
CommandError
(
"Unknown modulestore {}"
.
format
(
name
))
for
course
in
store
.
get_courses
():
course_id
=
course
.
location
.
course_id
output
.
append
(
course_id
)
return
'
\n
'
.
join
(
output
)
+
'
\n
'
lms/djangoapps/courseware/tests/test_commands.py
0 → 100644
View file @
956a960c
"""Tests for Django management commands"""
from
StringIO
import
StringIO
from
django.core.management
import
call_command
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.xml_importer
import
import_from_xml
DATA_DIR
=
'common/test/data/'
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
CommandTestCase
(
ModuleStoreTestCase
):
"""Parent class with helpers for testing management commands"""
def
load_courses
(
self
):
"""Load test courses and return list of ids"""
store
=
modulestore
()
import_from_xml
(
store
,
DATA_DIR
,
[
'toy'
,
'simple'
])
return
[
course
.
id
for
course
in
store
.
get_courses
()]
def
call_command
(
self
,
name
,
*
args
,
**
kwargs
):
"""Call management command and return output"""
out
=
StringIO
()
# To Capture the output of the command
call_command
(
name
,
*
args
,
stdout
=
out
,
**
kwargs
)
out
.
seek
(
0
)
return
out
.
read
()
class
CommandsTestCase
(
CommandTestCase
):
"""Test case for management commands"""
def
setUp
(
self
):
self
.
loaded_courses
=
self
.
load_courses
()
def
test_dump_course_ids
(
self
):
kwargs
=
{
'modulestore'
:
'default'
}
output
=
self
.
call_command
(
'dump_course_ids'
,
**
kwargs
)
dumped_courses
=
output
.
strip
()
.
split
(
'
\n
'
)
self
.
assertEqual
(
self
.
loaded_courses
,
dumped_courses
)
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