Skip to content

Commit 9de31fa

Browse files
committed
fix: fix test failures
1 parent 5269a05 commit 9de31fa

6 files changed

Lines changed: 34 additions & 16 deletions

File tree

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ disable =
275275
unspecified-encoding,
276276
unused-wildcard-import,
277277
use-maxsplit-arg,
278-
278+
279279
logging-fstring-interpolation,
280280

281281
[REPORTS]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ multi_line_output = 3
33
line_length = 120
44

55
[pycodestyle]
6-
exclude = ./.*,./docs/source/conf.py
6+
exclude = ./.*,./docs/source/conf.py,migrations
77
max-line-length = 120
88

99
[tool:pytest]

submissions/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class ExternalGraderDetailAdmin(admin.ModelAdmin):
171171
'id',
172172
'submission_info',
173173
'queue_name',
174-
'queue_key',
174+
'queue_key',
175175
'status_badge',
176176
'num_failures',
177177
'status_time',
@@ -188,7 +188,7 @@ class ExternalGraderDetailAdmin(admin.ModelAdmin):
188188

189189
search_fields = [
190190
'queue_name',
191-
'queue_key' ,
191+
'queue_key',
192192
'pullkey',
193193
'grader_file_name',
194194
'grader_reply',

submissions/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
TOP_SUBMISSIONS_CACHE_TIMEOUT = 300
5151

5252

53-
def create_external_grader_detail(student_item_dict,
53+
def create_external_grader_detail(student_item_dict, # pylint: disable=too-many-positional-arguments
5454
answer,
5555
queue_name: str,
5656
queue_key,

submissions/tests/test_api.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def test_get_or_create_student_item_race_condition__item_not_created(self):
879879
api._get_or_create_student_item(STUDENT_ITEM) # pylint: disable=protected-access
880880

881881
def test_create_external_grader_detail(self):
882-
external_grader_detail_data = {'queue_name': 'test_queue'}
882+
external_grader_detail_data = {'queue_name': 'test_queue', 'queue_key': 'test_key'}
883883
external_grader_detail = api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE,
884884
**external_grader_detail_data)
885885

@@ -890,11 +890,11 @@ def test_create_external_grader_detail(self):
890890
self.assertEqual(external_grader_detail.queue_name, 'test_queue')
891891

892892
def test_create_multiple_external_grader_detail(self):
893-
external_grader_detail_data1 = {'queue_name': 'test_queue'}
893+
external_grader_detail_data1 = {'queue_name': 'test_queue', 'queue_key': 'test_key'}
894894
external_grader_detail1 = api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE,
895895
**external_grader_detail_data1)
896896

897-
external_grader_detail_data2 = {'queue_name': 'test_queue'}
897+
external_grader_detail_data2 = {'queue_name': 'test_queue', 'queue_key': 'test_key'}
898898
external_grader_detail2 = api.create_external_grader_detail(SECOND_STUDENT_ITEM, ANSWER_ONE,
899899
**external_grader_detail_data2)
900900

@@ -917,13 +917,18 @@ def test_create_external_grader_detail_directly_database_error(self):
917917
mock_create.side_effect = DatabaseError("Database connection failed")
918918

919919
with self.assertRaises(api.SubmissionInternalError):
920-
api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE, queue_name="test_queue")
920+
api.create_external_grader_detail(
921+
STUDENT_ITEM, ANSWER_ONE, queue_name="test_queue", queue_key="test_key"
922+
)
921923

922924
def test_create_multiple_submission_external_grader_details(self):
923-
external_grader_detail1 = api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE, queue_name="shared_queue")
925+
external_grader_detail1 = api.create_external_grader_detail(
926+
STUDENT_ITEM, ANSWER_ONE, queue_name="shared_queue", queue_key="test_key"
927+
)
924928

925-
external_grader_detail2 = api.create_external_grader_detail(SECOND_STUDENT_ITEM, ANSWER_TWO,
926-
queue_name="shared_queue")
929+
external_grader_detail2 = api.create_external_grader_detail(
930+
SECOND_STUDENT_ITEM, ANSWER_TWO, queue_name="shared_queue", queue_key="test_key"
931+
)
927932

928933
submission1 = Submission.objects.get(uuid=external_grader_detail1.submission.uuid)
929934
self.assertEqual(external_grader_detail1.queue_name, 'shared_queue')
@@ -950,6 +955,7 @@ def __init__(self, file_content):
950955

951956
event_data = {
952957
'queue_name': 'test_queue',
958+
'queue_key': 'test_key',
953959
'files': {'test.txt': test_file}
954960
}
955961

@@ -978,6 +984,7 @@ def __init__(self, filename, content):
978984

979985
external_grader_detail = {
980986
'queue_name': 'test_queue',
987+
'queue_key': 'test_key',
981988
'files': test_files
982989
}
983990
external_grader_detail = api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE, **external_grader_detail)
@@ -988,7 +995,9 @@ def __init__(self, filename, content):
988995

989996
def test_create_external_grader_detail_without_files(self):
990997
"""Test creating a queue record without any files still works."""
991-
external_grader_instance = api.create_external_grader_detail(STUDENT_ITEM, ANSWER_ONE, queue_name="test_queue")
998+
external_grader_instance = api.create_external_grader_detail(
999+
STUDENT_ITEM, ANSWER_ONE, queue_name="test_queue", queue_key="test_key"
1000+
)
9921001
self.assertEqual(external_grader_instance.queue_name, 'test_queue')
9931002
self.assertEqual(external_grader_instance.files.count(), 0)
9941003

@@ -1008,6 +1017,7 @@ def setUp(self):
10081017
}
10091018
self.answer = "test answer"
10101019
self.queue_name = "test_queue"
1020+
self.queue_key = "test_key"
10111021

10121022
def test_create_external_grader_with_files(self):
10131023
"""Test processing files within create_external_grader_detail."""
@@ -1024,6 +1034,7 @@ def __init__(self):
10241034
student_item_dict=self.student_item_dict,
10251035
answer=self.answer,
10261036
queue_name=self.queue_name,
1037+
queue_key=self.queue_key,
10271038
files=files_dict
10281039
)
10291040

@@ -1046,6 +1057,7 @@ def __init__(self):
10461057
student_item_dict=self.student_item_dict,
10471058
answer=self.answer,
10481059
queue_name=self.queue_name,
1060+
queue_key=self.queue_key,
10491061
files={"test.txt": FileObjWithFileAttr()}
10501062
)
10511063

@@ -1076,6 +1088,7 @@ def __init__(self):
10761088
student_item_dict=self.student_item_dict,
10771089
answer=self.answer,
10781090
queue_name=self.queue_name,
1091+
queue_key=self.queue_key,
10791092
files=files_dict
10801093
)
10811094

@@ -1105,6 +1118,7 @@ def __init__(self):
11051118
student_item_dict=self.student_item_dict,
11061119
answer=self.answer,
11071120
queue_name=self.queue_name,
1121+
queue_key=self.queue_key,
11081122
files=files_dict
11091123
)
11101124

submissions/views/xqueue.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def put_result(self, request):
283283

284284
try:
285285
log.info(
286-
"Attempting to record score for submission %(submission_id)s (course=%(course_id)s, item=%(item_id)s, user=%(user_id)s)",
286+
"Attempting to record score for submission %(submission_id)s "
287+
"(course=%(course_id)s, item=%(item_id)s, user=%(user_id)s)",
287288
submission_context
288289
)
289290
set_score(
@@ -314,13 +315,16 @@ def put_result(self, request):
314315
)
315316
)
316317
log.info(
317-
"External grader score event emitted for submission %(submission_id)s (course=%(course_id)s, item=%(item_id)s, user=%(user_id)s, queue=%(queue_name)s, queue_key=%(queue_key)s)",
318+
"External grader score event emitted for submission %(submission_id)s "
319+
"(course=%(course_id)s, item=%(item_id)s, user=%(user_id)s, "
320+
"queue=%(queue_name)s, queue_key=%(queue_key)s)",
318321
submission_context
319322
)
320323

321324
except Exception:
322325
log.exception(
323-
"Error recording score for submission %(submission_id)s (course=%(course_id)s, item=%(item_id)s, user=%(user_id)s, queue=%(queue_name)s)",
326+
"Error recording score for submission %(submission_id)s "
327+
"(course=%(course_id)s, item=%(item_id)s, user=%(user_id)s, queue=%(queue_name)s)",
324328
submission_context
325329
)
326330
# Keep track of how many times we've failed to set_score a grade for this submission

0 commit comments

Comments
 (0)