Clean up pep8 E128 issues
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
escape(cdir),
|
||||
escape(cdir),
|
||||
course.location.url())
|
||||
html += '<li><a href="%s/migrate/reload/%s">%s</a> (%s)</li>' % (
|
||||
settings.MITX_ROOT_URL,
|
||||
escape(cdir),
|
||||
escape(cdir),
|
||||
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,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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user