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
6c0982b2
Commit
6c0982b2
authored
Feb 26, 2015
by
Calen Pennington
Committed by
Clinton Blackburn
Feb 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force GitExportError messages to be unicode objects
parent
7ac58129
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
cms/djangoapps/contentstore/git_export_utils.py
+4
-0
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
+11
-11
No files found.
cms/djangoapps/contentstore/git_export_utils.py
View file @
6c0982b2
...
...
@@ -30,6 +30,10 @@ class GitExportError(Exception):
Convenience exception class for git export error conditions.
"""
def
__init__
(
self
,
message
):
# Force the lazy i18n values to turn into actual unicode objects
super
(
GitExportError
,
self
)
.
__init__
(
unicode
(
message
))
NO_EXPORT_DIR
=
_
(
"GIT_REPO_EXPORT_DIR not set or path {0} doesn't exist, "
"please create it, or configure a different path with "
"GIT_REPO_EXPORT_DIR"
)
.
format
(
GIT_REPO_EXPORT_DIR
)
...
...
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
View file @
6c0982b2
...
...
@@ -69,13 +69,13 @@ class TestGitExport(CourseTestCase):
# Send bad url to get course not exported
with
self
.
assertRaises
(
SystemExit
)
as
ex
:
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
URL_BAD
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
URL_BAD
)):
call_command
(
'git_export'
,
'foo/bar/baz'
,
'silly'
,
stderr
=
StringIO
.
StringIO
())
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
# Send bad course_id to get course not exported
with
self
.
assertRaises
(
SystemExit
)
as
ex
:
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
BAD_COURSE
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
BAD_COURSE
)):
call_command
(
'git_export'
,
'foo/bar:baz'
,
'silly'
,
stderr
=
StringIO
.
StringIO
())
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
...
...
@@ -86,7 +86,7 @@ class TestGitExport(CourseTestCase):
"""
output
=
StringIO
.
StringIO
()
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
BAD_COURSE
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
BAD_COURSE
)):
call_command
(
'git_export'
,
'foo/bar:baz'
,
'silly'
,
stdout
=
output
,
stderr
=
output
...
...
@@ -96,7 +96,7 @@ class TestGitExport(CourseTestCase):
output
=
StringIO
.
StringIO
()
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
URL_BAD
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
URL_BAD
)):
call_command
(
'git_export'
,
'foo/bar/baz'
,
'silly'
,
stdout
=
output
,
stderr
=
output
...
...
@@ -113,14 +113,14 @@ class TestGitExport(CourseTestCase):
Test several bad URLs for validation
"""
course_key
=
SlashSeparatedCourseKey
(
'org'
,
'course'
,
'run'
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
URL_BAD
)):
with
self
.
assertRaisesRegexp
(
GitExportError
,
unicode
(
GitExportError
.
URL_BAD
)):
git_export_utils
.
export_to_git
(
course_key
,
'Sillyness'
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
URL_BAD
)):
with
self
.
assertRaisesRegexp
(
GitExportError
,
unicode
(
GitExportError
.
URL_BAD
)):
git_export_utils
.
export_to_git
(
course_key
,
'example.com:edx/notreal'
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
URL_NO_AUTH
)):
unicode
(
GitExportError
.
URL_NO_AUTH
)):
git_export_utils
.
export_to_git
(
course_key
,
'http://blah'
)
def
test_bad_git_repos
(
self
):
...
...
@@ -132,7 +132,7 @@ class TestGitExport(CourseTestCase):
course_key
=
SlashSeparatedCourseKey
(
'foo'
,
'blah'
,
'100-'
)
# Test bad clones
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_PULL
)):
unicode
(
GitExportError
.
CANNOT_PULL
)):
git_export_utils
.
export_to_git
(
course_key
,
'https://user:blah@example.com/test_repo.git'
)
...
...
@@ -140,14 +140,14 @@ class TestGitExport(CourseTestCase):
# Setup good repo with bad course to test xml export
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
XML_EXPORT_FAIL
)):
unicode
(
GitExportError
.
XML_EXPORT_FAIL
)):
git_export_utils
.
export_to_git
(
course_key
,
'file://{0}'
.
format
(
self
.
bare_repo_dir
))
# Test bad git remote after successful clone
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_PULL
)):
unicode
(
GitExportError
.
CANNOT_PULL
)):
git_export_utils
.
export_to_git
(
course_key
,
'https://user:blah@example.com/r.git'
)
...
...
@@ -204,6 +204,6 @@ class TestGitExport(CourseTestCase):
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_COMMIT
)):
unicode
(
GitExportError
.
CANNOT_COMMIT
)):
git_export_utils
.
export_to_git
(
self
.
course
.
id
,
'file://{0}'
.
format
(
self
.
bare_repo_dir
))
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