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
d5b3db89
Commit
d5b3db89
authored
Oct 27, 2017
by
bmedx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up tests to support updated management commands
parent
79fe2e62
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
27 deletions
+17
-27
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
+5
-8
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
+2
-2
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
+8
-15
cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py
+1
-1
cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py
+1
-1
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
View file @
d5b3db89
...
@@ -5,7 +5,6 @@ import ddt
...
@@ -5,7 +5,6 @@ import ddt
from
django.core.management
import
CommandError
,
call_command
from
django.core.management
import
CommandError
,
call_command
from
django.test
import
TestCase
from
django.test
import
TestCase
from
contentstore.management.commands.create_course
import
Command
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
...
@@ -18,26 +17,24 @@ class TestArgParsing(TestCase):
...
@@ -18,26 +17,24 @@ class TestArgParsing(TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestArgParsing
,
self
)
.
setUp
()
super
(
TestArgParsing
,
self
)
.
setUp
()
self
.
command
=
Command
()
def
test_no_args
(
self
):
def
test_no_args
(
self
):
errstring
=
"
create_course requires 5
arguments"
errstring
=
"
Error: too few
arguments"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
'create_course'
)
call_command
(
'create_course'
)
def
test_invalid_store
(
self
):
def
test_invalid_store
(
self
):
with
self
.
assertRaises
(
CommandError
):
with
self
.
assertRaises
(
CommandError
):
self
.
command
.
handle
(
"foo"
,
"user@foo.org"
,
"org"
,
"course"
,
"run"
)
call_command
(
'create_course'
,
"foo"
,
"user@foo.org"
,
"org"
,
"course"
,
"run"
)
def
test_nonexistent_user_id
(
self
):
def
test_nonexistent_user_id
(
self
):
errstring
=
"No user 99 found"
errstring
=
"No user 99 found"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"split"
,
"99"
,
"org"
,
"course"
,
"run"
)
call_command
(
'create_course'
,
"split"
,
"99"
,
"org"
,
"course"
,
"run"
)
def
test_nonexistent_user_email
(
self
):
def
test_nonexistent_user_email
(
self
):
errstring
=
"No user fake@example.com found"
errstring
=
"No user fake@example.com found"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"mongo"
,
"fake@example.com"
,
"org"
,
"course"
,
"run"
)
call_command
(
'create_course'
,
"mongo"
,
"fake@example.com"
,
"org"
,
"course"
,
"run"
)
@ddt.ddt
@ddt.ddt
...
...
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
View file @
d5b3db89
...
@@ -56,10 +56,10 @@ class TestGitExport(CourseTestCase):
...
@@ -56,10 +56,10 @@ class TestGitExport(CourseTestCase):
Test that the command interface works. Ignore stderr for clean
Test that the command interface works. Ignore stderr for clean
test output.
test output.
"""
"""
with
self
.
assertRaisesRegexp
(
CommandError
,
'
This script requires.
*'
):
with
self
.
assertRaisesRegexp
(
CommandError
,
'
Error: unrecognized arguments:
*'
):
call_command
(
'git_export'
,
'blah'
,
'blah'
,
'blah'
,
stderr
=
StringIO
.
StringIO
())
call_command
(
'git_export'
,
'blah'
,
'blah'
,
'blah'
,
stderr
=
StringIO
.
StringIO
())
with
self
.
assertRaises
Regexp
(
CommandError
,
'This script requires.*
'
):
with
self
.
assertRaises
Message
(
CommandError
,
'Error: too few arguments
'
):
call_command
(
'git_export'
,
stderr
=
StringIO
.
StringIO
())
call_command
(
'git_export'
,
stderr
=
StringIO
.
StringIO
())
# Send bad url to get course not exported
# Send bad url to get course not exported
...
...
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
View file @
d5b3db89
...
@@ -3,7 +3,6 @@ Unittests for migrating a course to split mongo
...
@@ -3,7 +3,6 @@ Unittests for migrating a course to split mongo
"""
"""
from
django.core.management
import
CommandError
,
call_command
from
django.core.management
import
CommandError
,
call_command
from
django.test
import
TestCase
from
django.test
import
TestCase
from
contentstore.management.commands.migrate_to_split
import
Command
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
@@ -17,15 +16,14 @@ class TestArgParsing(TestCase):
...
@@ -17,15 +16,14 @@ class TestArgParsing(TestCase):
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestArgParsing
,
self
)
.
setUp
()
super
(
TestArgParsing
,
self
)
.
setUp
()
self
.
command
=
Command
()
def
test_no_args
(
self
):
def
test_no_args
(
self
):
"""
"""
Test the arg length error
Test the arg length error
"""
"""
errstring
=
"
migrate_to_split requires at least two
arguments"
errstring
=
"
Error: too few
arguments"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
)
call_command
(
"migrate_to_split"
)
def
test_invalid_location
(
self
):
def
test_invalid_location
(
self
):
"""
"""
...
@@ -33,7 +31,7 @@ class TestArgParsing(TestCase):
...
@@ -33,7 +31,7 @@ class TestArgParsing(TestCase):
"""
"""
errstring
=
"Invalid location string"
errstring
=
"Invalid location string"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"foo"
,
"bar"
)
call_command
(
"migrate_to_split"
,
"foo"
,
"bar"
)
def
test_nonexistent_user_id
(
self
):
def
test_nonexistent_user_id
(
self
):
"""
"""
...
@@ -41,7 +39,7 @@ class TestArgParsing(TestCase):
...
@@ -41,7 +39,7 @@ class TestArgParsing(TestCase):
"""
"""
errstring
=
"No user found identified by 99"
errstring
=
"No user found identified by 99"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"org/course/name"
,
"99"
)
call_command
(
"migrate_to_split"
,
"org/course/name"
,
"99"
)
def
test_nonexistent_user_email
(
self
):
def
test_nonexistent_user_email
(
self
):
"""
"""
...
@@ -49,7 +47,7 @@ class TestArgParsing(TestCase):
...
@@ -49,7 +47,7 @@ class TestArgParsing(TestCase):
"""
"""
errstring
=
"No user found identified by fake@example.com"
errstring
=
"No user found identified by fake@example.com"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"org/course/name"
,
"fake@example.com"
)
call_command
(
"migrate_to_split"
,
"org/course/name"
,
"fake@example.com"
)
# pylint: disable=no-member, protected-access
# pylint: disable=no-member, protected-access
...
@@ -77,13 +75,6 @@ class TestMigrateToSplit(ModuleStoreTestCase):
...
@@ -77,13 +75,6 @@ class TestMigrateToSplit(ModuleStoreTestCase):
split_store
.
has_course
(
new_key
),
split_store
.
has_course
(
new_key
),
"Could not find course"
"Could not find course"
)
)
# I put this in but realized that the migrator doesn't make the new course the
# default mapping in mixed modulestore. I left the test here so we can debate what it ought to do.
# self.assertEqual(
# ModuleStoreEnum.Type.split,
# modulestore()._get_modulestore_for_courselike(new_key).get_modulestore_type(),
# "Split is not the new default for the course"
# )
def
test_user_id
(
self
):
def
test_user_id
(
self
):
"""
"""
...
@@ -104,7 +95,9 @@ class TestMigrateToSplit(ModuleStoreTestCase):
...
@@ -104,7 +95,9 @@ class TestMigrateToSplit(ModuleStoreTestCase):
"migrate_to_split"
,
"migrate_to_split"
,
str
(
self
.
course
.
id
),
str
(
self
.
course
.
id
),
str
(
self
.
user
.
id
),
str
(
self
.
user
.
id
),
"org.dept"
,
"name"
,
"run"
,
org
=
"org.dept"
,
course
=
"name"
,
run
=
"run"
,
)
)
split_store
=
modulestore
()
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
split
)
split_store
=
modulestore
()
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
split
)
locator
=
split_store
.
make_course_key
(
"org.dept"
,
"name"
,
"run"
)
locator
=
split_store
.
make_course_key
(
"org.dept"
,
"name"
,
"run"
)
...
...
cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py
View file @
d5b3db89
...
@@ -48,7 +48,7 @@ class TestReindexCourse(ModuleStoreTestCase):
...
@@ -48,7 +48,7 @@ class TestReindexCourse(ModuleStoreTestCase):
def
test_given_no_arguments_raises_command_error
(
self
):
def
test_given_no_arguments_raises_command_error
(
self
):
""" Test that raises CommandError for incorrect arguments """
""" Test that raises CommandError for incorrect arguments """
with
self
.
assertRaisesRegexp
(
CommandError
,
".* requires one or more
arguments.
*"
):
with
self
.
assertRaisesRegexp
(
CommandError
,
".* requires one or more *"
):
call_command
(
'reindex_course'
)
call_command
(
'reindex_course'
)
@ddt.data
(
'qwerty'
,
'invalid_key'
,
'xblockv1:qwerty'
)
@ddt.data
(
'qwerty'
,
'invalid_key'
,
'xblockv1:qwerty'
)
...
...
cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py
View file @
d5b3db89
...
@@ -49,7 +49,7 @@ class TestReindexLibrary(ModuleStoreTestCase):
...
@@ -49,7 +49,7 @@ class TestReindexLibrary(ModuleStoreTestCase):
def
test_given_no_arguments_raises_command_error
(
self
):
def
test_given_no_arguments_raises_command_error
(
self
):
""" Test that raises CommandError for incorrect arguments """
""" Test that raises CommandError for incorrect arguments """
with
self
.
assertRaisesRegexp
(
CommandError
,
".* requires one or more
arguments.
*"
):
with
self
.
assertRaisesRegexp
(
CommandError
,
".* requires one or more *"
):
call_command
(
'reindex_library'
)
call_command
(
'reindex_library'
)
@ddt.data
(
'qwerty'
,
'invalid_key'
,
'xblock-v1:qwe+rty'
)
@ddt.data
(
'qwerty'
,
'invalid_key'
,
'xblock-v1:qwe+rty'
)
...
...
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