From f08dc42802ce0442744f250c4f329db5cc7bae03 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Fri, 24 Jan 2014 13:23:47 -0500 Subject: [PATCH] Add some dummy arg parsing tests --- .../commands/tests/test_migrate_to_split.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py 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 new file mode 100644 index 0000000000..f800b2f62a --- /dev/null +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py @@ -0,0 +1,33 @@ +""" +Unittests for importing a course via management command +""" + +import unittest + +from django.core.management import CommandError +from contentstore.management.commands.migrate_to_split import Command + + +class TestArgParsing(unittest.TestCase): + def setUp(self): + self.command = Command() + + def test_no_args(self): + errstring = "migrate_to_split requires at least two arguments" + with self.assertRaisesRegexp(CommandError, errstring): + self.command.handle() + + def test_invalid_location(self): + errstring = "Invalid location string" + with self.assertRaisesRegexp(CommandError, errstring): + self.command.handle("foo", "bar") + + def test_nonexistant_user_id(self): + errstring = "No user exists with ID 99" + with self.assertRaisesRegexp(CommandError, errstring): + self.command.handle("i4x://org/course/category/name", "99") + + def test_nonexistant_user_email(self): + 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")