From 3816ac2ab0d3b9241e795e2b48f9ba8c354c0c19 Mon Sep 17 00:00:00 2001 From: Carson Gee Date: Mon, 10 Nov 2014 14:50:07 -0500 Subject: [PATCH] Correct unresolved ugettext_lazy error strings in git_export command --- .../management/commands/git_export.py | 4 +-- .../commands/tests/test_git_export.py | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/git_export.py b/cms/djangoapps/contentstore/management/commands/git_export.py index 1bc7f18337..5182127dca 100644 --- a/cms/djangoapps/contentstore/management/commands/git_export.py +++ b/cms/djangoapps/contentstore/management/commands/git_export.py @@ -62,7 +62,7 @@ class Command(BaseCommand): try: course_key = SlashSeparatedCourseKey.from_deprecated_string(args[0]) except InvalidKeyError: - raise CommandError(GitExportError.BAD_COURSE) + raise CommandError(_(GitExportError.BAD_COURSE)) try: git_export_utils.export_to_git( @@ -72,4 +72,4 @@ class Command(BaseCommand): options.get('rdir', None) ) except git_export_utils.GitExportError as ex: - raise CommandError(str(ex)) + raise CommandError(_(ex.message)) 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 5166e1aaf6..7c6c4965de 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -80,6 +80,34 @@ class TestGitExport(CourseTestCase): stderr=StringIO.StringIO()) self.assertEqual(ex.exception.code, 1) + def test_error_output(self): + """ + Verify that error output is actually resolved as the correct string + """ + output = StringIO.StringIO() + with self.assertRaises(SystemExit): + with self.assertRaisesRegexp(CommandError, GitExportError.BAD_COURSE): + call_command( + 'git_export', 'foo/bar:baz', 'silly', + stdout=output, stderr=output + ) + self.assertIn('Bad course location provided', output.getvalue()) + output.close() + + output = StringIO.StringIO() + with self.assertRaises(SystemExit): + with self.assertRaisesRegexp(CommandError, GitExportError.URL_BAD): + call_command( + 'git_export', 'foo/bar/baz', 'silly', + stdout=output, stderr=output + ) + self.assertIn( + 'Non writable git url provided. Expecting something like:' + ' git@github.com:mitocw/edx4edx_lite.git', + output.getvalue() + ) + output.close() + def test_bad_git_url(self): """ Test several bad URLs for validation