Commit 2c60a7db by cahrens

pep8 cleanup

parent 318372f2
...@@ -8,10 +8,12 @@ from django.contrib.auth.models import User ...@@ -8,10 +8,12 @@ from django.contrib.auth.models import User
from auth.authz import add_user_to_creator_group, remove_user_from_creator_group, is_user_in_creator_group from auth.authz import add_user_to_creator_group, remove_user_from_creator_group, is_user_in_creator_group
class CreatorGroupTest(TestCase): class CreatorGroupTest(TestCase):
""" """
Tests for the course creator group. Tests for the course creator group.
""" """
def setUp(self): def setUp(self):
""" Test case setup """ """ Test case setup """
self.user = User.objects.create_user('testuser', 'test+courses@edx.org', 'foo') self.user = User.objects.create_user('testuser', 'test+courses@edx.org', 'foo')
...@@ -25,7 +27,7 @@ class CreatorGroupTest(TestCase): ...@@ -25,7 +27,7 @@ class CreatorGroupTest(TestCase):
def test_creator_group_enabled_but_empty(self): def test_creator_group_enabled_but_empty(self):
""" Tests creator group feature on, but group empty. """ """ Tests creator group feature on, but group empty. """
with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP" : True}): with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP": True}):
self.assertFalse(is_user_in_creator_group(self.user)) self.assertFalse(is_user_in_creator_group(self.user))
# Make user staff. This will cause is_user_in_creator_group to return True. # Make user staff. This will cause is_user_in_creator_group to return True.
...@@ -34,7 +36,7 @@ class CreatorGroupTest(TestCase): ...@@ -34,7 +36,7 @@ class CreatorGroupTest(TestCase):
def test_creator_group_enabled_nonempty(self): def test_creator_group_enabled_nonempty(self):
""" Tests creator group feature on, user added. """ """ Tests creator group feature on, user added. """
with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP" : True}): with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP": True}):
self.assertTrue(add_user_to_creator_group(self.user)) self.assertTrue(add_user_to_creator_group(self.user))
self.assertTrue(is_user_in_creator_group(self.user)) self.assertTrue(is_user_in_creator_group(self.user))
...@@ -62,7 +64,8 @@ class CreatorGroupTest(TestCase): ...@@ -62,7 +64,8 @@ class CreatorGroupTest(TestCase):
def test_course_creation_disabled(self): def test_course_creation_disabled(self):
""" Tests that the COURSE_CREATION_DISABLED flag overrides course creator group settings. """ """ Tests that the COURSE_CREATION_DISABLED flag overrides course creator group settings. """
with mock.patch.dict('django.conf.settings.MITX_FEATURES', {'DISABLE_COURSE_CREATION': True, "ENABLE_CREATOR_GROUP" : True}): with mock.patch.dict('django.conf.settings.MITX_FEATURES',
{'DISABLE_COURSE_CREATION': True, "ENABLE_CREATOR_GROUP": True}):
# Add user to creator group. # Add user to creator group.
self.assertTrue(add_user_to_creator_group(self.user)) self.assertTrue(add_user_to_creator_group(self.user))
......
...@@ -531,7 +531,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -531,7 +531,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self.assertGreater(len(all_assets), 0) self.assertGreater(len(all_assets), 0)
# make sure we have some thumbnails in our trashcan # make sure we have some thumbnails in our trashcan
all_thumbnails = trash_store.get_all_content_thumbnails_for_course(course_location) _all_thumbnails = trash_store.get_all_content_thumbnails_for_course(course_location)
# #
# cdodge: temporarily comment out assertion on thumbnails because many environments # cdodge: temporarily comment out assertion on thumbnails because many environments
# will not have the jpeg converter installed and this test will fail # will not have the jpeg converter installed and this test will fail
...@@ -592,20 +592,18 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -592,20 +592,18 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
location = Location('i4x://MITx/999/chapter/neuvo') location = Location('i4x://MITx/999/chapter/neuvo')
self.assertRaises(InvalidVersionError, draft_store.clone_item, 'i4x://edx/templates/chapter/Empty', self.assertRaises(InvalidVersionError, draft_store.clone_item, 'i4x://edx/templates/chapter/Empty',
location) location)
direct_store.clone_item('i4x://edx/templates/chapter/Empty', location) direct_store.clone_item('i4x://edx/templates/chapter/Empty', location)
self.assertRaises(InvalidVersionError, draft_store.clone_item, location, self.assertRaises(InvalidVersionError, draft_store.clone_item, location, location)
location)
self.assertRaises(InvalidVersionError, draft_store.update_item, location, self.assertRaises(InvalidVersionError, draft_store.update_item, location, 'chapter data')
'chapter data')
# taking advantage of update_children and other functions never checking that the ids are valid # taking advantage of update_children and other functions never checking that the ids are valid
self.assertRaises(InvalidVersionError, draft_store.update_children, location, self.assertRaises(InvalidVersionError, draft_store.update_children, location,
['i4x://MITx/999/problem/doesntexist']) ['i4x://MITx/999/problem/doesntexist'])
self.assertRaises(InvalidVersionError, draft_store.update_metadata, location, self.assertRaises(InvalidVersionError, draft_store.update_metadata, location,
{'due': datetime.datetime.now(UTC)}) {'due': datetime.datetime.now(UTC)})
self.assertRaises(InvalidVersionError, draft_store.unpublish, location) self.assertRaises(InvalidVersionError, draft_store.unpublish, location)
...@@ -903,7 +901,8 @@ class ContentStoreTest(ModuleStoreTestCase): ...@@ -903,7 +901,8 @@ class ContentStoreTest(ModuleStoreTestCase):
def test_create_course_with_bad_organization(self): def test_create_course_with_bad_organization(self):
"""Test new course creation - error path for bad organization name""" """Test new course creation - error path for bad organization name"""
self.course_data['org'] = 'University of California, Berkeley' self.course_data['org'] = 'University of California, Berkeley'
self.assert_course_creation_failed("Unable to create course 'Robot Super Course'.\n\nInvalid characters in 'University of California, Berkeley'.") self.assert_course_creation_failed(
"Unable to create course 'Robot Super Course'.\n\nInvalid characters in 'University of California, Berkeley'.")
def test_create_course_with_course_creation_disabled_staff(self): def test_create_course_with_course_creation_disabled_staff(self):
"""Test new course creation -- course creation disabled, but staff access.""" """Test new course creation -- course creation disabled, but staff access."""
...@@ -924,14 +923,14 @@ class ContentStoreTest(ModuleStoreTestCase): ...@@ -924,14 +923,14 @@ class ContentStoreTest(ModuleStoreTestCase):
def test_create_course_no_course_creators_not_staff(self): def test_create_course_no_course_creators_not_staff(self):
"""Test new course creation -- error path for course creator group enabled, not staff, group is empty.""" """Test new course creation -- error path for course creator group enabled, not staff, group is empty."""
with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP" : True}): with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP": True}):
self.user.is_staff = False self.user.is_staff = False
self.user.save() self.user.save()
self.assert_course_permission_denied() self.assert_course_permission_denied()
def test_create_course_with_course_creator(self): def test_create_course_with_course_creator(self):
"""Test new course creation -- use course creator group""" """Test new course creation -- use course creator group"""
with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP" : True}): with mock.patch.dict('django.conf.settings.MITX_FEATURES', {"ENABLE_CREATOR_GROUP": True}):
add_user_to_creator_group(self.user) add_user_to_creator_group(self.user)
self.assert_created_course() self.assert_created_course()
......
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