diff --git a/lms/djangoapps/foldit/tests.py b/lms/djangoapps/foldit/tests.py index 9928f596be..d391dd3650 100644 --- a/lms/djangoapps/foldit/tests.py +++ b/lms/djangoapps/foldit/tests.py @@ -95,13 +95,19 @@ class FolditTestCase(TestCase): response = self.make_puzzle_score_request([1, 2], [0.078034, 0.080000]) self.assertEqual(response.content, json.dumps( - [{"OperationID": "SetPlayerPuzzleScores", - "Value": [{ - "PuzzleID": 1, - "Status": "Success"}, - - {"PuzzleID": 2, - "Status": "Success"}]}])) + [{ + "OperationID": "SetPlayerPuzzleScores", + "Value": [ + { + "PuzzleID": 1, + "Status": "Success" + }, { + "PuzzleID": 2, + "Status": "Success" + } + ] + }] + )) def test_SetPlayerPuzzleScores_multiple(self): @@ -126,9 +132,11 @@ class FolditTestCase(TestCase): self.assertEqual(len(top_10), 1) # Floats always get in the way, so do almostequal - self.assertAlmostEqual(top_10[0]['score'], - Score.display_score(better_score), - delta=0.5) + self.assertAlmostEqual( + top_10[0]['score'], + Score.display_score(better_score), + delta=0.5 + ) # reporting a worse score shouldn't worse_score = 0.065 @@ -137,9 +145,11 @@ class FolditTestCase(TestCase): top_10 = Score.get_tops_n(10, puzzle_id) self.assertEqual(len(top_10), 1) # should still be the better score - self.assertAlmostEqual(top_10[0]['score'], - Score.display_score(better_score), - delta=0.5) + self.assertAlmostEqual( + top_10[0]['score'], + Score.display_score(better_score), + delta=0.5 + ) def test_SetPlayerPuzzleScores_manyplayers(self): """ @@ -150,28 +160,34 @@ class FolditTestCase(TestCase): puzzle_id = ['1'] player1_score = 0.08 player2_score = 0.02 - response1 = self.make_puzzle_score_request(puzzle_id, player1_score, - self.user) + response1 = self.make_puzzle_score_request( + puzzle_id, player1_score, self.user + ) # There should now be a score in the db. top_10 = Score.get_tops_n(10, puzzle_id) self.assertEqual(len(top_10), 1) self.assertEqual(top_10[0]['score'], Score.display_score(player1_score)) - response2 = self.make_puzzle_score_request(puzzle_id, player2_score, - self.user2) + response2 = self.make_puzzle_score_request( + puzzle_id, player2_score, self.user2 + ) # There should now be two scores in the db top_10 = Score.get_tops_n(10, puzzle_id) self.assertEqual(len(top_10), 2) # Top score should be player2_score. Second should be player1_score - self.assertAlmostEqual(top_10[0]['score'], - Score.display_score(player2_score), - delta=0.5) - self.assertAlmostEqual(top_10[1]['score'], - Score.display_score(player1_score), - delta=0.5) + self.assertAlmostEqual( + top_10[0]['score'], + Score.display_score(player2_score), + delta=0.5 + ) + self.assertAlmostEqual( + top_10[1]['score'], + Score.display_score(player1_score), + delta=0.5 + ) # Top score user should be self.user2.username self.assertEqual(top_10[0]['username'], self.user2.username) diff --git a/lms/djangoapps/foldit/views.py b/lms/djangoapps/foldit/views.py index da361a2a82..8d52e09aa1 100644 --- a/lms/djangoapps/foldit/views.py +++ b/lms/djangoapps/foldit/views.py @@ -36,9 +36,13 @@ def foldit_ops(request): "Success": "false", "ErrorString": "Verification failed", "ErrorCode": "VerifyFailed"}) - log.warning("Verification of SetPlayerPuzzleScores failed:" + - "user %s, scores json %r, verify %r", - request.user, puzzle_scores_json, pz_verify_json) + log.warning( + "Verification of SetPlayerPuzzleScores failed:" + "user %s, scores json %r, verify %r", + request.user, + puzzle_scores_json, + pz_verify_json + ) else: # This is needed because we are not getting valid json - the # value of ScoreType is an unquoted string. Right now regexes are @@ -65,9 +69,13 @@ def foldit_ops(request): "Success": "false", "ErrorString": "Verification failed", "ErrorCode": "VerifyFailed"}) - log.warning("Verification of SetPuzzlesComplete failed:" + - " user %s, puzzles json %r, verify %r", - request.user, puzzles_complete_json, pc_verify_json) + log.warning( + "Verification of SetPuzzlesComplete failed:" + " user %s, puzzles json %r, verify %r", + request.user, + puzzles_complete_json, + pc_verify_json + ) else: puzzles_complete = json.loads(puzzles_complete_json) responses.append(save_complete(request.user, puzzles_complete)) diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py index f1ebf814fa..f01cc4e3ad 100644 --- a/lms/djangoapps/instructor_task/models.py +++ b/lms/djangoapps/instructor_task/models.py @@ -84,13 +84,15 @@ class InstructorTask(models.Model): raise ValueError(msg) # create the task, then save it: - instructor_task = cls(course_id=course_id, - task_type=task_type, - task_id=task_id, - task_key=task_key, - task_input=json_task_input, - task_state=QUEUING, - requester=requester) + instructor_task = cls( + course_id=course_id, + task_type=task_type, + task_id=task_id, + task_key=task_key, + task_input=json_task_input, + task_state=QUEUING, + requester=requester + ) instructor_task.save_now() return instructor_task diff --git a/lms/djangoapps/lms_migration/migrate.py b/lms/djangoapps/lms_migration/migrate.py index a677383035..83af73a842 100644 --- a/lms/djangoapps/lms_migration/migrate.py +++ b/lms/djangoapps/lms_migration/migrate.py @@ -118,10 +118,12 @@ def manage_modulestores(request, reload_dir=None, commit_id=None): html += '

Courses loaded in the modulestore

' html += '
    ' for cdir, course in def_ms.courses.items(): - html += '
  1. %s (%s)
  2. ' % (settings.MITX_ROOT_URL, - escape(cdir), - escape(cdir), - course.location.url()) + html += '
  3. %s (%s)
  4. ' % ( + settings.MITX_ROOT_URL, + escape(cdir), + escape(cdir), + course.location.url() + ) html += '
' #---------------------------------------- diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index 2c611b4481..6b2b4707bb 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -270,8 +270,10 @@ def get_problem_list(request, course_id): mimetype="application/json") except GradingServiceError: #This is a dev_facing_error - log.exception("Error from staff grading service in open ended grading. server url: {0}" - .format(staff_grading_service().url)) + log.exception( + "Error from staff grading service in open " + "ended grading. server url: {0}".format(staff_grading_service().url) + ) #This is a staff_facing_error return HttpResponse(json.dumps({'success': False, 'error': STAFF_ERROR_MESSAGE})) @@ -285,8 +287,10 @@ def _get_next(course_id, grader_id, location): return staff_grading_service().get_next(course_id, location, grader_id) except GradingServiceError: #This is a dev facing error - log.exception("Error from staff grading service in open ended grading. server url: {0}" - .format(staff_grading_service().url)) + log.exception( + "Error from staff grading service in open " + "ended grading. server url: {0}".format(staff_grading_service().url) + ) #This is a staff_facing_error return json.dumps({'success': False, 'error': STAFF_ERROR_MESSAGE}) diff --git a/lms/djangoapps/static_template_view/tests.py b/lms/djangoapps/static_template_view/tests.py index 9cd5502d5d..813a94e294 100644 --- a/lms/djangoapps/static_template_view/tests.py +++ b/lms/djangoapps/static_template_view/tests.py @@ -21,23 +21,24 @@ class SimpleTest(TestCase): """ # since I had to remap files, pedantically test all press releases # published to date. Decent positive test while we're at it. - all_releases = ["/press/mit-and-harvard-announce-edx", - "/press/uc-berkeley-joins-edx", - "/press/edX-announces-proctored-exam-testing", - "/press/elsevier-collaborates-with-edx", - "/press/ut-joins-edx", - "/press/cengage-to-provide-book-content", - "/press/gates-foundation-announcement", - "/press/wellesley-college-joins-edx", - "/press/georgetown-joins-edx", - "/press/spring-courses", - "/press/lewin-course-announcement", - "/press/bostonx-announcement", - "/press/eric-lander-secret-of-life", - "/press/edx-expands-internationally", - "/press/xblock_announcement", - "/press/stanford-to-work-with-edx", - ] + all_releases = [ + "/press/mit-and-harvard-announce-edx", + "/press/uc-berkeley-joins-edx", + "/press/edX-announces-proctored-exam-testing", + "/press/elsevier-collaborates-with-edx", + "/press/ut-joins-edx", + "/press/cengage-to-provide-book-content", + "/press/gates-foundation-announcement", + "/press/wellesley-college-joins-edx", + "/press/georgetown-joins-edx", + "/press/spring-courses", + "/press/lewin-course-announcement", + "/press/bostonx-announcement", + "/press/eric-lander-secret-of-life", + "/press/edx-expands-internationally", + "/press/xblock_announcement", + "/press/stanford-to-work-with-edx", + ] for rel in all_releases: response = self.client.get(rel) @@ -55,7 +56,7 @@ class SimpleTest(TestCase): response = self.client.get("/press/../homework.html") self.assertEqual(response.status_code, 404) - # "." in is ascii 2E + # "." in is ascii 2E response = self.client.get("/press/%2E%2E/homework.html") self.assertEqual(response.status_code, 404) diff --git a/lms/djangoapps/static_template_view/views.py b/lms/djangoapps/static_template_view/views.py index 56a7f32780..e5a8c43ca8 100644 --- a/lms/djangoapps/static_template_view/views.py +++ b/lms/djangoapps/static_template_view/views.py @@ -15,10 +15,11 @@ from util.cache import cache_if_anonymous valid_templates = [] if settings.STATIC_GRAB: - valid_templates = valid_templates + ['server-down.html', - 'server-error.html' - 'server-overloaded.html', - ] + valid_templates = valid_templates + [ + 'server-down.html', + 'server-error.html' + 'server-overloaded.html', + ] def index(request, template): diff --git a/lms/lib/comment_client/legacy.py b/lms/lib/comment_client/legacy.py index fbf66a09fd..de7ce201ce 100644 --- a/lms/lib/comment_client/legacy.py +++ b/lms/lib/comment_client/legacy.py @@ -5,16 +5,14 @@ def delete_threads(commentable_id, *args, **kwargs): def get_threads(commentable_id, recursive=False, query_params={}, *args, **kwargs): default_params = {'page': 1, 'per_page': 20, 'recursive': recursive} attributes = dict(default_params.items() + query_params.items()) - response = _perform_request('get', _url_for_threads(commentable_id), \ - attributes, *args, **kwargs) + response = _perform_request('get', _url_for_threads(commentable_id), attributes, *args, **kwargs) return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1) def search_threads(course_id, recursive=False, query_params={}, *args, **kwargs): default_params = {'page': 1, 'per_page': 20, 'course_id': course_id, 'recursive': recursive} attributes = dict(default_params.items() + query_params.items()) - response = _perform_request('get', _url_for_search_threads(), \ - attributes, *args, **kwargs) + response = _perform_request('get', _url_for_search_threads(), attributes, *args, **kwargs) return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)