Commit 308fe26b by Calen Pennington

Clean up pep8 E128 issues

parent 6fe56ac9
...@@ -95,13 +95,19 @@ class FolditTestCase(TestCase): ...@@ -95,13 +95,19 @@ class FolditTestCase(TestCase):
response = self.make_puzzle_score_request([1, 2], [0.078034, 0.080000]) response = self.make_puzzle_score_request([1, 2], [0.078034, 0.080000])
self.assertEqual(response.content, json.dumps( self.assertEqual(response.content, json.dumps(
[{"OperationID": "SetPlayerPuzzleScores", [{
"Value": [{ "OperationID": "SetPlayerPuzzleScores",
"PuzzleID": 1, "Value": [
"Status": "Success"}, {
"PuzzleID": 1,
{"PuzzleID": 2, "Status": "Success"
"Status": "Success"}]}])) }, {
"PuzzleID": 2,
"Status": "Success"
}
]
}]
))
def test_SetPlayerPuzzleScores_multiple(self): def test_SetPlayerPuzzleScores_multiple(self):
...@@ -126,9 +132,11 @@ class FolditTestCase(TestCase): ...@@ -126,9 +132,11 @@ class FolditTestCase(TestCase):
self.assertEqual(len(top_10), 1) self.assertEqual(len(top_10), 1)
# Floats always get in the way, so do almostequal # Floats always get in the way, so do almostequal
self.assertAlmostEqual(top_10[0]['score'], self.assertAlmostEqual(
Score.display_score(better_score), top_10[0]['score'],
delta=0.5) Score.display_score(better_score),
delta=0.5
)
# reporting a worse score shouldn't # reporting a worse score shouldn't
worse_score = 0.065 worse_score = 0.065
...@@ -137,9 +145,11 @@ class FolditTestCase(TestCase): ...@@ -137,9 +145,11 @@ class FolditTestCase(TestCase):
top_10 = Score.get_tops_n(10, puzzle_id) top_10 = Score.get_tops_n(10, puzzle_id)
self.assertEqual(len(top_10), 1) self.assertEqual(len(top_10), 1)
# should still be the better score # should still be the better score
self.assertAlmostEqual(top_10[0]['score'], self.assertAlmostEqual(
Score.display_score(better_score), top_10[0]['score'],
delta=0.5) Score.display_score(better_score),
delta=0.5
)
def test_SetPlayerPuzzleScores_manyplayers(self): def test_SetPlayerPuzzleScores_manyplayers(self):
""" """
...@@ -150,28 +160,34 @@ class FolditTestCase(TestCase): ...@@ -150,28 +160,34 @@ class FolditTestCase(TestCase):
puzzle_id = ['1'] puzzle_id = ['1']
player1_score = 0.08 player1_score = 0.08
player2_score = 0.02 player2_score = 0.02
response1 = self.make_puzzle_score_request(puzzle_id, player1_score, response1 = self.make_puzzle_score_request(
self.user) puzzle_id, player1_score, self.user
)
# There should now be a score in the db. # There should now be a score in the db.
top_10 = Score.get_tops_n(10, puzzle_id) top_10 = Score.get_tops_n(10, puzzle_id)
self.assertEqual(len(top_10), 1) self.assertEqual(len(top_10), 1)
self.assertEqual(top_10[0]['score'], Score.display_score(player1_score)) self.assertEqual(top_10[0]['score'], Score.display_score(player1_score))
response2 = self.make_puzzle_score_request(puzzle_id, player2_score, response2 = self.make_puzzle_score_request(
self.user2) puzzle_id, player2_score, self.user2
)
# There should now be two scores in the db # There should now be two scores in the db
top_10 = Score.get_tops_n(10, puzzle_id) top_10 = Score.get_tops_n(10, puzzle_id)
self.assertEqual(len(top_10), 2) self.assertEqual(len(top_10), 2)
# Top score should be player2_score. Second should be player1_score # Top score should be player2_score. Second should be player1_score
self.assertAlmostEqual(top_10[0]['score'], self.assertAlmostEqual(
Score.display_score(player2_score), top_10[0]['score'],
delta=0.5) Score.display_score(player2_score),
self.assertAlmostEqual(top_10[1]['score'], delta=0.5
Score.display_score(player1_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 # Top score user should be self.user2.username
self.assertEqual(top_10[0]['username'], self.user2.username) self.assertEqual(top_10[0]['username'], self.user2.username)
......
...@@ -36,9 +36,13 @@ def foldit_ops(request): ...@@ -36,9 +36,13 @@ def foldit_ops(request):
"Success": "false", "Success": "false",
"ErrorString": "Verification failed", "ErrorString": "Verification failed",
"ErrorCode": "VerifyFailed"}) "ErrorCode": "VerifyFailed"})
log.warning("Verification of SetPlayerPuzzleScores failed:" + log.warning(
"user %s, scores json %r, verify %r", "Verification of SetPlayerPuzzleScores failed:"
request.user, puzzle_scores_json, pz_verify_json) "user %s, scores json %r, verify %r",
request.user,
puzzle_scores_json,
pz_verify_json
)
else: else:
# This is needed because we are not getting valid json - the # This is needed because we are not getting valid json - the
# value of ScoreType is an unquoted string. Right now regexes are # value of ScoreType is an unquoted string. Right now regexes are
...@@ -65,9 +69,13 @@ def foldit_ops(request): ...@@ -65,9 +69,13 @@ def foldit_ops(request):
"Success": "false", "Success": "false",
"ErrorString": "Verification failed", "ErrorString": "Verification failed",
"ErrorCode": "VerifyFailed"}) "ErrorCode": "VerifyFailed"})
log.warning("Verification of SetPuzzlesComplete failed:" + log.warning(
" user %s, puzzles json %r, verify %r", "Verification of SetPuzzlesComplete failed:"
request.user, puzzles_complete_json, pc_verify_json) " user %s, puzzles json %r, verify %r",
request.user,
puzzles_complete_json,
pc_verify_json
)
else: else:
puzzles_complete = json.loads(puzzles_complete_json) puzzles_complete = json.loads(puzzles_complete_json)
responses.append(save_complete(request.user, puzzles_complete)) responses.append(save_complete(request.user, puzzles_complete))
......
...@@ -84,13 +84,15 @@ class InstructorTask(models.Model): ...@@ -84,13 +84,15 @@ class InstructorTask(models.Model):
raise ValueError(msg) raise ValueError(msg)
# create the task, then save it: # create the task, then save it:
instructor_task = cls(course_id=course_id, instructor_task = cls(
task_type=task_type, course_id=course_id,
task_id=task_id, task_type=task_type,
task_key=task_key, task_id=task_id,
task_input=json_task_input, task_key=task_key,
task_state=QUEUING, task_input=json_task_input,
requester=requester) task_state=QUEUING,
requester=requester
)
instructor_task.save_now() instructor_task.save_now()
return instructor_task return instructor_task
......
...@@ -118,10 +118,12 @@ def manage_modulestores(request, reload_dir=None, commit_id=None): ...@@ -118,10 +118,12 @@ def manage_modulestores(request, reload_dir=None, commit_id=None):
html += '<h2>Courses loaded in the modulestore</h2>' html += '<h2>Courses loaded in the modulestore</h2>'
html += '<ol>' html += '<ol>'
for cdir, course in def_ms.courses.items(): for cdir, course in def_ms.courses.items():
html += '<li><a href="%s/migrate/reload/%s">%s</a> (%s)</li>' % (settings.MITX_ROOT_URL, html += '<li><a href="%s/migrate/reload/%s">%s</a> (%s)</li>' % (
escape(cdir), settings.MITX_ROOT_URL,
escape(cdir), escape(cdir),
course.location.url()) escape(cdir),
course.location.url()
)
html += '</ol>' html += '</ol>'
#---------------------------------------- #----------------------------------------
......
...@@ -270,8 +270,10 @@ def get_problem_list(request, course_id): ...@@ -270,8 +270,10 @@ def get_problem_list(request, course_id):
mimetype="application/json") mimetype="application/json")
except GradingServiceError: except GradingServiceError:
#This is a dev_facing_error #This is a dev_facing_error
log.exception("Error from staff grading service in open ended grading. server url: {0}" log.exception(
.format(staff_grading_service().url)) "Error from staff grading service in open "
"ended grading. server url: {0}".format(staff_grading_service().url)
)
#This is a staff_facing_error #This is a staff_facing_error
return HttpResponse(json.dumps({'success': False, return HttpResponse(json.dumps({'success': False,
'error': STAFF_ERROR_MESSAGE})) 'error': STAFF_ERROR_MESSAGE}))
...@@ -285,8 +287,10 @@ def _get_next(course_id, grader_id, location): ...@@ -285,8 +287,10 @@ def _get_next(course_id, grader_id, location):
return staff_grading_service().get_next(course_id, location, grader_id) return staff_grading_service().get_next(course_id, location, grader_id)
except GradingServiceError: except GradingServiceError:
#This is a dev facing error #This is a dev facing error
log.exception("Error from staff grading service in open ended grading. server url: {0}" log.exception(
.format(staff_grading_service().url)) "Error from staff grading service in open "
"ended grading. server url: {0}".format(staff_grading_service().url)
)
#This is a staff_facing_error #This is a staff_facing_error
return json.dumps({'success': False, return json.dumps({'success': False,
'error': STAFF_ERROR_MESSAGE}) 'error': STAFF_ERROR_MESSAGE})
......
...@@ -21,23 +21,24 @@ class SimpleTest(TestCase): ...@@ -21,23 +21,24 @@ class SimpleTest(TestCase):
""" """
# since I had to remap files, pedantically test all press releases # since I had to remap files, pedantically test all press releases
# published to date. Decent positive test while we're at it. # published to date. Decent positive test while we're at it.
all_releases = ["/press/mit-and-harvard-announce-edx", all_releases = [
"/press/uc-berkeley-joins-edx", "/press/mit-and-harvard-announce-edx",
"/press/edX-announces-proctored-exam-testing", "/press/uc-berkeley-joins-edx",
"/press/elsevier-collaborates-with-edx", "/press/edX-announces-proctored-exam-testing",
"/press/ut-joins-edx", "/press/elsevier-collaborates-with-edx",
"/press/cengage-to-provide-book-content", "/press/ut-joins-edx",
"/press/gates-foundation-announcement", "/press/cengage-to-provide-book-content",
"/press/wellesley-college-joins-edx", "/press/gates-foundation-announcement",
"/press/georgetown-joins-edx", "/press/wellesley-college-joins-edx",
"/press/spring-courses", "/press/georgetown-joins-edx",
"/press/lewin-course-announcement", "/press/spring-courses",
"/press/bostonx-announcement", "/press/lewin-course-announcement",
"/press/eric-lander-secret-of-life", "/press/bostonx-announcement",
"/press/edx-expands-internationally", "/press/eric-lander-secret-of-life",
"/press/xblock_announcement", "/press/edx-expands-internationally",
"/press/stanford-to-work-with-edx", "/press/xblock_announcement",
] "/press/stanford-to-work-with-edx",
]
for rel in all_releases: for rel in all_releases:
response = self.client.get(rel) response = self.client.get(rel)
...@@ -55,7 +56,7 @@ class SimpleTest(TestCase): ...@@ -55,7 +56,7 @@ class SimpleTest(TestCase):
response = self.client.get("/press/../homework.html") response = self.client.get("/press/../homework.html")
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
# "." in is ascii 2E # "." in is ascii 2E
response = self.client.get("/press/%2E%2E/homework.html") response = self.client.get("/press/%2E%2E/homework.html")
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
...@@ -15,10 +15,11 @@ from util.cache import cache_if_anonymous ...@@ -15,10 +15,11 @@ from util.cache import cache_if_anonymous
valid_templates = [] valid_templates = []
if settings.STATIC_GRAB: if settings.STATIC_GRAB:
valid_templates = valid_templates + ['server-down.html', valid_templates = valid_templates + [
'server-error.html' 'server-down.html',
'server-overloaded.html', 'server-error.html'
] 'server-overloaded.html',
]
def index(request, template): def index(request, template):
......
...@@ -5,16 +5,14 @@ def delete_threads(commentable_id, *args, **kwargs): ...@@ -5,16 +5,14 @@ def delete_threads(commentable_id, *args, **kwargs):
def get_threads(commentable_id, recursive=False, query_params={}, *args, **kwargs): def get_threads(commentable_id, recursive=False, query_params={}, *args, **kwargs):
default_params = {'page': 1, 'per_page': 20, 'recursive': recursive} default_params = {'page': 1, 'per_page': 20, 'recursive': recursive}
attributes = dict(default_params.items() + query_params.items()) attributes = dict(default_params.items() + query_params.items())
response = _perform_request('get', _url_for_threads(commentable_id), \ response = _perform_request('get', _url_for_threads(commentable_id), attributes, *args, **kwargs)
attributes, *args, **kwargs)
return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1) return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)
def search_threads(course_id, recursive=False, query_params={}, *args, **kwargs): def search_threads(course_id, recursive=False, query_params={}, *args, **kwargs):
default_params = {'page': 1, 'per_page': 20, 'course_id': course_id, 'recursive': recursive} default_params = {'page': 1, 'per_page': 20, 'course_id': course_id, 'recursive': recursive}
attributes = dict(default_params.items() + query_params.items()) attributes = dict(default_params.items() + query_params.items())
response = _perform_request('get', _url_for_search_threads(), \ response = _perform_request('get', _url_for_search_threads(), attributes, *args, **kwargs)
attributes, *args, **kwargs)
return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1) return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)
......
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