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
80eed36c
Commit
80eed36c
authored
Feb 26, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7124 from edx/django-upgrade/unicode-export-errors
Force GitExportError messages to be unicode objects
parents
bbab3a39
6c0982b2
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 @
80eed36c
...
@@ -30,6 +30,10 @@ class GitExportError(Exception):
...
@@ -30,6 +30,10 @@ class GitExportError(Exception):
Convenience exception class for git export error conditions.
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, "
NO_EXPORT_DIR
=
_
(
"GIT_REPO_EXPORT_DIR not set or path {0} doesn't exist, "
"please create it, or configure a different path with "
"please create it, or configure a different path with "
"GIT_REPO_EXPORT_DIR"
)
.
format
(
GIT_REPO_EXPORT_DIR
)
"GIT_REPO_EXPORT_DIR"
)
.
format
(
GIT_REPO_EXPORT_DIR
)
...
...
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
View file @
80eed36c
...
@@ -69,13 +69,13 @@ class TestGitExport(CourseTestCase):
...
@@ -69,13 +69,13 @@ class TestGitExport(CourseTestCase):
# Send bad url to get course not exported
# Send bad url to get course not exported
with
self
.
assertRaises
(
SystemExit
)
as
ex
:
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'
,
call_command
(
'git_export'
,
'foo/bar/baz'
,
'silly'
,
stderr
=
StringIO
.
StringIO
())
stderr
=
StringIO
.
StringIO
())
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
# Send bad course_id to get course not exported
# Send bad course_id to get course not exported
with
self
.
assertRaises
(
SystemExit
)
as
ex
:
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'
,
call_command
(
'git_export'
,
'foo/bar:baz'
,
'silly'
,
stderr
=
StringIO
.
StringIO
())
stderr
=
StringIO
.
StringIO
())
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
...
@@ -86,7 +86,7 @@ class TestGitExport(CourseTestCase):
...
@@ -86,7 +86,7 @@ class TestGitExport(CourseTestCase):
"""
"""
output
=
StringIO
.
StringIO
()
output
=
StringIO
.
StringIO
()
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
BAD_COURSE
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
BAD_COURSE
)):
call_command
(
call_command
(
'git_export'
,
'foo/bar:baz'
,
'silly'
,
'git_export'
,
'foo/bar:baz'
,
'silly'
,
stdout
=
output
,
stderr
=
output
stdout
=
output
,
stderr
=
output
...
@@ -96,7 +96,7 @@ class TestGitExport(CourseTestCase):
...
@@ -96,7 +96,7 @@ class TestGitExport(CourseTestCase):
output
=
StringIO
.
StringIO
()
output
=
StringIO
.
StringIO
()
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaisesRegexp
(
CommandError
,
str
(
GitExportError
.
URL_BAD
)):
with
self
.
assertRaisesRegexp
(
CommandError
,
unicode
(
GitExportError
.
URL_BAD
)):
call_command
(
call_command
(
'git_export'
,
'foo/bar/baz'
,
'silly'
,
'git_export'
,
'foo/bar/baz'
,
'silly'
,
stdout
=
output
,
stderr
=
output
stdout
=
output
,
stderr
=
output
...
@@ -113,14 +113,14 @@ class TestGitExport(CourseTestCase):
...
@@ -113,14 +113,14 @@ class TestGitExport(CourseTestCase):
Test several bad URLs for validation
Test several bad URLs for validation
"""
"""
course_key
=
SlashSeparatedCourseKey
(
'org'
,
'course'
,
'run'
)
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'
)
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'
)
git_export_utils
.
export_to_git
(
course_key
,
'example.com:edx/notreal'
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
URL_NO_AUTH
)):
unicode
(
GitExportError
.
URL_NO_AUTH
)):
git_export_utils
.
export_to_git
(
course_key
,
'http://blah'
)
git_export_utils
.
export_to_git
(
course_key
,
'http://blah'
)
def
test_bad_git_repos
(
self
):
def
test_bad_git_repos
(
self
):
...
@@ -132,7 +132,7 @@ class TestGitExport(CourseTestCase):
...
@@ -132,7 +132,7 @@ class TestGitExport(CourseTestCase):
course_key
=
SlashSeparatedCourseKey
(
'foo'
,
'blah'
,
'100-'
)
course_key
=
SlashSeparatedCourseKey
(
'foo'
,
'blah'
,
'100-'
)
# Test bad clones
# Test bad clones
with
self
.
assertRaisesRegexp
(
GitExportError
,
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_PULL
)):
unicode
(
GitExportError
.
CANNOT_PULL
)):
git_export_utils
.
export_to_git
(
git_export_utils
.
export_to_git
(
course_key
,
course_key
,
'https://user:blah@example.com/test_repo.git'
)
'https://user:blah@example.com/test_repo.git'
)
...
@@ -140,14 +140,14 @@ class TestGitExport(CourseTestCase):
...
@@ -140,14 +140,14 @@ class TestGitExport(CourseTestCase):
# Setup good repo with bad course to test xml export
# Setup good repo with bad course to test xml export
with
self
.
assertRaisesRegexp
(
GitExportError
,
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
XML_EXPORT_FAIL
)):
unicode
(
GitExportError
.
XML_EXPORT_FAIL
)):
git_export_utils
.
export_to_git
(
git_export_utils
.
export_to_git
(
course_key
,
course_key
,
'file://{0}'
.
format
(
self
.
bare_repo_dir
))
'file://{0}'
.
format
(
self
.
bare_repo_dir
))
# Test bad git remote after successful clone
# Test bad git remote after successful clone
with
self
.
assertRaisesRegexp
(
GitExportError
,
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_PULL
)):
unicode
(
GitExportError
.
CANNOT_PULL
)):
git_export_utils
.
export_to_git
(
git_export_utils
.
export_to_git
(
course_key
,
course_key
,
'https://user:blah@example.com/r.git'
)
'https://user:blah@example.com/r.git'
)
...
@@ -204,6 +204,6 @@ class TestGitExport(CourseTestCase):
...
@@ -204,6 +204,6 @@ class TestGitExport(CourseTestCase):
)
)
with
self
.
assertRaisesRegexp
(
GitExportError
,
with
self
.
assertRaisesRegexp
(
GitExportError
,
str
(
GitExportError
.
CANNOT_COMMIT
)):
unicode
(
GitExportError
.
CANNOT_COMMIT
)):
git_export_utils
.
export_to_git
(
git_export_utils
.
export_to_git
(
self
.
course
.
id
,
'file://{0}'
.
format
(
self
.
bare_repo_dir
))
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