diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py index b6a5920f73..70122aa5cb 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py @@ -5,7 +5,6 @@ import ddt from django.core.management import CommandError, call_command from django.test import TestCase -from contentstore.management.commands.create_course import Command from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore @@ -18,26 +17,24 @@ class TestArgParsing(TestCase): def setUp(self): super(TestArgParsing, self).setUp() - self.command = Command() - def test_no_args(self): - errstring = "create_course requires 5 arguments" + errstring = "Error: too few arguments" with self.assertRaisesRegexp(CommandError, errstring): - self.command.handle('create_course') + call_command('create_course') def test_invalid_store(self): 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): errstring = "No user 99 found" 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): errstring = "No user fake@example.com found" 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 diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py index 14c36448c2..9b2583b85f 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -56,10 +56,10 @@ class TestGitExport(CourseTestCase): Test that the command interface works. Ignore stderr for clean 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()) - with self.assertRaisesRegexp(CommandError, 'This script requires.*'): + with self.assertRaisesMessage(CommandError, 'Error: too few arguments'): call_command('git_export', stderr=StringIO.StringIO()) # Send bad url to get course not exported diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py index 1af93bed15..2d68db80fb 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py @@ -3,7 +3,6 @@ Unittests for migrating a course to split mongo """ from django.core.management import CommandError, call_command from django.test import TestCase -from contentstore.management.commands.migrate_to_split import Command from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory @@ -17,15 +16,14 @@ class TestArgParsing(TestCase): """ def setUp(self): super(TestArgParsing, self).setUp() - self.command = Command() def test_no_args(self): """ Test the arg length error """ - errstring = "migrate_to_split requires at least two arguments" + errstring = "Error: too few arguments" with self.assertRaisesRegexp(CommandError, errstring): - self.command.handle() + call_command("migrate_to_split") def test_invalid_location(self): """ @@ -33,7 +31,7 @@ class TestArgParsing(TestCase): """ errstring = "Invalid location string" with self.assertRaisesRegexp(CommandError, errstring): - self.command.handle("foo", "bar") + call_command("migrate_to_split", "foo", "bar") def test_nonexistent_user_id(self): """ @@ -41,7 +39,7 @@ class TestArgParsing(TestCase): """ errstring = "No user found identified by 99" 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): """ @@ -49,7 +47,7 @@ class TestArgParsing(TestCase): """ errstring = "No user found identified by fake@example.com" 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 @@ -77,13 +75,6 @@ class TestMigrateToSplit(ModuleStoreTestCase): split_store.has_course(new_key), "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): """ @@ -104,7 +95,9 @@ class TestMigrateToSplit(ModuleStoreTestCase): "migrate_to_split", str(self.course.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) locator = split_store.make_course_key("org.dept", "name", "run") diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py index 3d3d99b91a..6603c0c399 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_courses.py @@ -48,7 +48,7 @@ class TestReindexCourse(ModuleStoreTestCase): def test_given_no_arguments_raises_command_error(self): """ 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') @ddt.data('qwerty', 'invalid_key', 'xblockv1:qwerty') diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py index d44b8a3886..0bb7a58de6 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_reindex_library.py @@ -49,7 +49,7 @@ class TestReindexLibrary(ModuleStoreTestCase): def test_given_no_arguments_raises_command_error(self): """ 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') @ddt.data('qwerty', 'invalid_key', 'xblock-v1:qwe+rty')