Merge pull request #5910 from mitocw/cg/git_export_error_output
Correct unresolved ugettext_lazy error strings in git_export command
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user