Commit 308fe26b by Calen Pennington

Clean up pep8 E128 issues

parent 6fe56ac9
......@@ -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": [{
[{
"OperationID": "SetPlayerPuzzleScores",
"Value": [
{
"PuzzleID": 1,
"Status": "Success"},
{"PuzzleID": 2,
"Status": "Success"}]}]))
"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'],
self.assertAlmostEqual(
top_10[0]['score'],
Score.display_score(better_score),
delta=0.5)
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'],
self.assertAlmostEqual(
top_10[0]['score'],
Score.display_score(better_score),
delta=0.5)
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'],
self.assertAlmostEqual(
top_10[0]['score'],
Score.display_score(player2_score),
delta=0.5)
self.assertAlmostEqual(top_10[1]['score'],
delta=0.5
)
self.assertAlmostEqual(
top_10[1]['score'],
Score.display_score(player1_score),
delta=0.5)
delta=0.5
)
# Top score user should be self.user2.username
self.assertEqual(top_10[0]['username'], self.user2.username)
......
......@@ -36,9 +36,13 @@ def foldit_ops(request):
"Success": "false",
"ErrorString": "Verification failed",
"ErrorCode": "VerifyFailed"})
log.warning("Verification of SetPlayerPuzzleScores failed:" +
log.warning(
"Verification of SetPlayerPuzzleScores failed:"
"user %s, scores json %r, verify %r",
request.user, puzzle_scores_json, pz_verify_json)
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:" +
log.warning(
"Verification of SetPuzzlesComplete failed:"
" user %s, puzzles json %r, verify %r",
request.user, puzzles_complete_json, pc_verify_json)
request.user,
puzzles_complete_json,
pc_verify_json
)
else:
puzzles_complete = json.loads(puzzles_complete_json)
responses.append(save_complete(request.user, puzzles_complete))
......
......@@ -84,13 +84,15 @@ class InstructorTask(models.Model):
raise ValueError(msg)
# create the task, then save it:
instructor_task = cls(course_id=course_id,
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)
requester=requester
)
instructor_task.save_now()
return instructor_task
......
......@@ -118,10 +118,12 @@ def manage_modulestores(request, reload_dir=None, commit_id=None):
html += '<h2>Courses loaded in the modulestore</h2>'
html += '<ol>'
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>' % (
settings.MITX_ROOT_URL,
escape(cdir),
escape(cdir),
course.location.url())
course.location.url()
)
html += '</ol>'
#----------------------------------------
......
......@@ -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})
......
......@@ -21,7 +21,8 @@ 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",
all_releases = [
"/press/mit-and-harvard-announce-edx",
"/press/uc-berkeley-joins-edx",
"/press/edX-announces-proctored-exam-testing",
"/press/elsevier-collaborates-with-edx",
......
......@@ -15,7 +15,8 @@ from util.cache import cache_if_anonymous
valid_templates = []
if settings.STATIC_GRAB:
valid_templates = valid_templates + ['server-down.html',
valid_templates = valid_templates + [
'server-down.html',
'server-error.html'
'server-overloaded.html',
]
......
......@@ -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)
......
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