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
de96a47e
Commit
de96a47e
authored
Jan 24, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
happy path unit test
parent
f08dc428
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
cms/djangoapps/contentstore/management/commands/migrate_to_split.py
+5
-8
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
+30
-2
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+4
-1
No files found.
cms/djangoapps/contentstore/management/commands/migrate_to_split.py
View file @
de96a47e
...
...
@@ -8,6 +8,7 @@ from xmodule.modulestore import Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.split_migrator
import
SplitMigrator
from
xmodule.modulestore
import
InvalidLocationError
from
xmodule.modulestore.django
import
loc_mapper
class
Command
(
BaseCommand
):
...
...
@@ -60,15 +61,11 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
location
,
user
,
locator_string
=
self
.
parse_args
(
*
args
)
draft
=
modulestore
(
'default'
)
direct
=
modulestore
(
'direct'
)
split
=
modulestore
(
'split'
)
migrator
=
SplitMigrator
(
draft_modulestore
=
draft
,
direct_modulestore
=
direct
,
split_modulestore
=
split
,
loc_mapper
=
split
.
loc_mapper
,
draft_modulestore
=
modulestore
(
'default'
)
,
direct_modulestore
=
modulestore
(
'direct'
)
,
split_modulestore
=
modulestore
(
'split'
)
,
loc_mapper
=
loc_mapper
()
,
)
migrator
.
migrate_mongo_course
(
location
,
user
,
locator_string
)
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
View file @
de96a47e
"""
Unittests for importing a course via management command
"""
import
unittest
from
django.core.management
import
CommandError
from
django.core.management
import
CommandError
,
call_command
from
django.test.utils
import
override_settings
from
contentstore.management.commands.migrate_to_split
import
Command
from
contentstore.tests.modulestore_config
import
TEST_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
loc_mapper
class
TestArgParsing
(
unittest
.
TestCase
):
...
...
@@ -31,3 +37,25 @@ class TestArgParsing(unittest.TestCase):
errstring
=
"No user exists with email fake@example.com"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"i4x://org/course/category/name"
,
"fake@example.com"
)
@override_settings
(
MODULESTORE
=
TEST_MODULESTORE
)
class
TestMigrateToSplit
(
ModuleStoreTestCase
):
"""
Unit tests for importing a course from command line
"""
def
setUp
(
self
):
super
(
TestMigrateToSplit
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
()
self
.
user
=
UserFactory
()
def
test_happy_path
(
self
):
call_command
(
"migrate_to_split"
,
str
(
self
.
course
.
location
),
self
.
user
.
email
,
)
locator
=
loc_mapper
()
.
translate_location
(
self
.
course
.
id
,
self
.
course
.
location
)
course_from_split
=
modulestore
(
'split'
)
.
get_course
(
locator
)
self
.
assertIsNotNone
(
course_from_split
)
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
de96a47e
...
...
@@ -5,7 +5,7 @@ Modulestore configuration for test cases.
from
uuid
import
uuid4
from
django.test
import
TestCase
from
xmodule.modulestore.django
import
editable_modulestore
,
\
clear_existing_modulestores
clear_existing_modulestores
,
loc_mapper
from
xmodule.contentstore.django
import
contentstore
...
...
@@ -225,6 +225,9 @@ class ModuleStoreTestCase(TestCase):
if
contentstore
()
.
fs_files
:
db
=
contentstore
()
.
fs_files
.
database
db
.
connection
.
drop_database
(
db
)
lm
=
loc_mapper
()
if
lm
.
db
:
lm
.
location_map
.
drop
()
@classmethod
def
setUpClass
(
cls
):
...
...
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