Merge pull request #5905 from edx/renzo/pep8-pylint-cleanup

Clean up pep8 and pylint violations
This commit is contained in:
Renzo Lucioni
2014-11-12 14:34:03 -05:00
18 changed files with 222 additions and 68 deletions

View File

@@ -250,4 +250,4 @@ SORTED_COUNTRIES = [
(u'ZM', u'Zambia'),
(u'ZW', u'Zimbabwe'),
(u'AX', u'\xc5land Islands')
]
]

View File

@@ -14,12 +14,12 @@ from user_api.helpers import (
class FakeInputException(Exception):
"""Fake exception that should be intercepted. """
"""Fake exception that should be intercepted."""
pass
class FakeOutputException(Exception):
"""Fake exception that should be raised. """
"""Fake exception that should be raised."""
pass
@@ -36,9 +36,7 @@ def intercepted_function(raise_error=None):
class InterceptErrorsTest(TestCase):
"""
Tests for the decorator that intercepts errors.
"""
"""Tests for the decorator that intercepts errors."""
@raises(FakeOutputException)
def test_intercepts_errors(self):
@@ -73,7 +71,7 @@ class InterceptErrorsTest(TestCase):
class FormDescriptionTest(TestCase):
"""Tests of helper functions which generate form descriptions."""
def test_to_json(self):
desc = FormDescription("post", "/submit")
desc.add_field(
@@ -134,7 +132,7 @@ class FormDescriptionTest(TestCase):
@ddt.ddt
class StudentViewShimTest(TestCase):
"Tests of the student view shim."
def setUp(self):
self.captured_request = None
@@ -211,8 +209,8 @@ class StudentViewShimTest(TestCase):
response = view(HttpRequest())
self.assertEqual(response.status_code, 403)
def _shimmed_view(self, response, check_logged_in=False):
def stub_view(request):
def _shimmed_view(self, response, check_logged_in=False): # pylint: disable=missing-docstring
def stub_view(request): # pylint: disable=missing-docstring
self.captured_request = request
return response
return shim_student_view(stub_view, check_logged_in=check_logged_in)

View File

@@ -112,6 +112,11 @@ class ApiTestCase(TestCase):
self.assertEqual(response.status_code, 405)
def assertAuthDisabled(self, method, uri):
"""
Assert that the Django rest framework does not interpret basic auth
headers for views exposed to anonymous users as an attempt to authenticate.
"""
# Django rest framework interprets basic auth headers
# as an attempt to authenticate with the API.
# We don't want this for views available to anonymous users.
@@ -987,7 +992,7 @@ class RegistrationViewTest(ApiTestCase):
)
def test_register_form_year_of_birth(self):
this_year = datetime.datetime.now(UTC).year
this_year = datetime.datetime.now(UTC).year # pylint: disable=maybe-no-member
year_options = (
[{"value": "", "name": "--", "default": True}] + [
{"value": unicode(year), "name": unicode(year)}
@@ -1067,13 +1072,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required"},
{
"label": "I agree to the <a href=\"https://www.test.com/honor\">Terms of Service and Honor Code</a>",
"label": "I agree to the {platform_name} <a href=\"https://www.test.com/honor\">Terms of Service and Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "honor_code",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"https://www.test.com/honor\">Terms of Service and Honor Code</a>"
"required": "You must agree to the {platform_name} <a href=\"https://www.test.com/honor\">Terms of Service and Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1084,13 +1093,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required"},
{
"label": "I agree to the <a href=\"/honor\">Terms of Service and Honor Code</a>",
"label": "I agree to the {platform_name} <a href=\"/honor\">Terms of Service and Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "honor_code",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"/honor\">Terms of Service and Honor Code</a>"
"required": "You must agree to the {platform_name} <a href=\"/honor\">Terms of Service and Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1107,13 +1120,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required", "terms_of_service": "required"},
{
"label": "I agree to the <a href=\"https://www.test.com/honor\">Honor Code</a>",
"label": "I agree to the {platform_name} <a href=\"https://www.test.com/honor\">Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "honor_code",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"https://www.test.com/honor\">Honor Code</a>"
"required": "You must agree to the {platform_name} <a href=\"https://www.test.com/honor\">Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1122,13 +1139,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required", "terms_of_service": "required"},
{
"label": "I agree to the <a href=\"https://www.test.com/tos\">Terms of Service</a>",
"label": "I agree to the {platform_name} <a href=\"https://www.test.com/tos\">Terms of Service</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "terms_of_service",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"https://www.test.com/tos\">Terms of Service</a>"
"required": "You must agree to the {platform_name} <a href=\"https://www.test.com/tos\">Terms of Service</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1141,13 +1162,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required", "terms_of_service": "required"},
{
"label": "I agree to the <a href=\"/honor\">Honor Code</a>",
"label": "I agree to the {platform_name} <a href=\"/honor\">Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "honor_code",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"/honor\">Honor Code</a>"
"required": "You must agree to the {platform_name} <a href=\"/honor\">Honor Code</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1156,13 +1181,17 @@ class RegistrationViewTest(ApiTestCase):
self._assert_reg_field(
{"honor_code": "required", "terms_of_service": "required"},
{
"label": "I agree to the <a href=\"/tos\">Terms of Service</a>",
"label": "I agree to the {platform_name} <a href=\"/tos\">Terms of Service</a>.".format(
platform_name=settings.PLATFORM_NAME
),
"name": "terms_of_service",
"defaultValue": False,
"type": "checkbox",
"required": True,
"errorMessages": {
"required": "You must agree to the <a href=\"/tos\">Terms of Service</a>"
"required": "You must agree to the {platform_name} <a href=\"/tos\">Terms of Service</a>.".format(
platform_name=settings.PLATFORM_NAME
)
}
}
)
@@ -1372,7 +1401,7 @@ class RegistrationViewTest(ApiTestCase):
self.assertEqual(response.status_code, 409)
self.assertEqual(
response.content,
"It looks like {} belongs to an existing account. Try again with a different email address and username.".format(
"It looks like {} belongs to an existing account. Try again with a different username.".format(
self.USERNAME
)
)