Commit a28b02ae by Julian Arni

Pep8 and pylint fixes

parent fcd11d93
......@@ -32,10 +32,10 @@ class ImportTestCase(CourseTestCase):
os.utime(name, None)
# Create tar test files -----------------------------------------------
# OK course:
# OK course:
good_dir = tempfile.mkdtemp(dir=self.content_dir)
os.makedirs(os.path.join(good_dir, "course"))
with open(os.path.join(good_dir, "course.xml") , "w+") as f:
with open(os.path.join(good_dir, "course.xml"), "w+") as f:
f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>')
with open(os.path.join(good_dir, "course", "2013_Spring.xml"), "w+") as f:
......@@ -44,7 +44,7 @@ class ImportTestCase(CourseTestCase):
self.good_tar = os.path.join(self.content_dir, "good.tar.gz")
with tarfile.open(self.good_tar, "w:gz") as gtar:
gtar.add(good_dir)
# Bad course (no 'course.xml' file):
bad_dir = tempfile.mkdtemp(dir=self.content_dir)
touch(os.path.join(bad_dir, "bad.xml"))
......@@ -62,11 +62,11 @@ class ImportTestCase(CourseTestCase):
"""
with open(self.bad_tar) as btar:
resp = self.client.post(
self.url,
{
"name": self.bad_tar,
"course-data": [btar]
})
self.url,
{
"name": self.bad_tar,
"course-data": [btar]
})
self.assertEquals(resp.status_code, 415)
def test_with_coursexml(self):
......@@ -82,4 +82,3 @@ class ImportTestCase(CourseTestCase):
"course-data": [gtar]
})
self.assert2XX(resp.status_code)
......@@ -19,7 +19,6 @@ from django.core.files.temp import NamedTemporaryFile
from django.views.decorators.http import require_http_methods
from mitxmako.shortcuts import render_to_response
from cache_toolbox.core import del_cached_content
from auth.authz import create_all_course_groups
from xmodule.modulestore.xml_importer import import_from_xml
......@@ -38,7 +37,7 @@ __all__ = ['import_course', 'generate_export_course', 'export_course']
log = logging.getLogger(__name__)
MAX_UP_LENGTH = 20000352 # Max chunk size for uploads
MAX_UP_LENGTH = 20000352 # Max chunk size for uploads
# Regex to capture Content-Range header ranges.
CONTENT_RE = re.compile(r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11})")
......@@ -113,18 +112,18 @@ def import_course(request, org, course, name):
if int(content_range['stop']) != int(content_range['end']) - 1:
# More chunks coming
return JsonResponse({
"files": [{
"name": filename,
"size": size,
"deleteUrl": "",
"deleteType": "",
"url": reverse('import_course', kwargs={
'org': location.org,
'course': location.course,
'name': location.name
}),
"thumbnailUrl": ""
}]
"files": [{
"name": filename,
"size": size,
"deleteUrl": "",
"deleteType": "",
"url": reverse('import_course', kwargs={
'org': location.org,
'course': location.course,
'name': location.name
}),
"thumbnailUrl": ""
}]
})
else: # This was the last chunk.
......@@ -147,7 +146,7 @@ def import_course(request, org, course, name):
def get_all_files(directory):
"""
For each file in the directory, yield a 2-tuple of (file-name,
directory-path)
directory-path)
"""
for dirpath, _dirnames, filenames in os.walk(directory):
for filename in filenames:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment