author aarif <mraarif@outlook.com> 1562661182 +0500
committer root <root@lms.devstack.edx> 1563270070 +0000

ran python-modernize and isort on files mentioned in INCR-327

changes made to comply with pylint

changes made to comply with pylint and pass failing test

changes made to comply with pylint
This commit is contained in:
aarif
2019-07-09 13:33:02 +05:00
committed by root
parent c89ecb384f
commit 5f5b2ddc12
9 changed files with 90 additions and 57 deletions

View File

@@ -1,10 +1,14 @@
"""
Content library unit tests that require the CMS runtime.
"""
from __future__ import absolute_import
import ddt
import six
from django.test.utils import override_settings
from mock import Mock, patch
from opaque_keys.edx.locator import CourseKey, LibraryLocator
from six.moves import range
from contentstore.tests.utils import AjaxEnabledTestClient, parse_json
from contentstore.utils import reverse_library_url, reverse_url, reverse_usage_url
@@ -81,7 +85,7 @@ class LibraryTestCase(ModuleStoreTestCase):
parent_location=course.location,
user_id=self.user.id,
publish_item=publish_item,
source_library_id=unicode(library_key),
source_library_id=six.text_type(library_key),
**(other_settings or {})
)
@@ -511,11 +515,11 @@ class TestLibraryAccess(LibraryTestCase):
`library` can be a LibraryLocator or the library's root XBlock
"""
if isinstance(library, (basestring, LibraryLocator)):
if isinstance(library, (six.string_types, LibraryLocator)):
lib_key = library
else:
lib_key = library.location.library_key
response = self.client.get(reverse_library_url('library_handler', unicode(lib_key)))
response = self.client.get(reverse_library_url('library_handler', six.text_type(lib_key)))
self.assertIn(response.status_code, (200, 302, 403))
return response.status_code == 200
@@ -579,7 +583,7 @@ class TestLibraryAccess(LibraryTestCase):
# Now non_staff_user should be able to access library2_key only:
lib_list = self._list_libraries()
self.assertEqual(len(lib_list), 1)
self.assertEqual(lib_list[0]["library_key"], unicode(library2_key))
self.assertEqual(lib_list[0]["library_key"], six.text_type(library2_key))
self.assertTrue(self._can_access_library(library2_key))
self.assertFalse(self._can_access_library(self.library))
@@ -606,7 +610,7 @@ class TestLibraryAccess(LibraryTestCase):
# Now non_staff_user should be able to access lib_key_pacific only:
lib_list = self._list_libraries()
self.assertEqual(len(lib_list), 1)
self.assertEqual(lib_list[0]["library_key"], unicode(lib_key_pacific))
self.assertEqual(lib_list[0]["library_key"], six.text_type(lib_key_pacific))
self.assertTrue(self._can_access_library(lib_key_pacific))
self.assertFalse(self._can_access_library(lib_key_atlantic))
self.assertFalse(self._can_access_library(self.lib_key))
@@ -646,8 +650,8 @@ class TestLibraryAccess(LibraryTestCase):
def can_copy_block():
""" Check if studio lets us duplicate the XBlock in the library """
response = self.client.ajax_post(reverse_url('xblock_handler'), {
'parent_locator': unicode(self.library.location),
'duplicate_source_locator': unicode(block.location),
'parent_locator': six.text_type(self.library.location),
'duplicate_source_locator': six.text_type(block.location),
})
self.assertIn(response.status_code, (200, 403)) # 400 would be ambiguous
return response.status_code == 200
@@ -655,7 +659,7 @@ class TestLibraryAccess(LibraryTestCase):
def can_create_block():
""" Check if studio lets us make a new XBlock in the library """
response = self.client.ajax_post(reverse_url('xblock_handler'), {
'parent_locator': unicode(self.library.location), 'category': 'html',
'parent_locator': six.text_type(self.library.location), 'category': 'html',
})
self.assertIn(response.status_code, (200, 403)) # 400 would be ambiguous
return response.status_code == 200
@@ -708,8 +712,8 @@ class TestLibraryAccess(LibraryTestCase):
# Copy block to the course:
response = self.client.ajax_post(reverse_url('xblock_handler'), {
'parent_locator': unicode(course.location),
'duplicate_source_locator': unicode(block.location),
'parent_locator': six.text_type(course.location),
'duplicate_source_locator': six.text_type(block.location),
})
self.assertIn(response.status_code, (200, 403)) # 400 would be ambiguous
duplicate_action_allowed = (response.status_code == 200)