-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing test for AckReportComputedTask #49
Conversation
) | ||
message_timestamp = datetime.datetime.now(timezone.utc) | ||
new_message = Message( | ||
type = self.force_golem_data.__class__.__name__, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#20 has been merged. Please change it to numeric TYPE
.
@@ -355,6 +355,56 @@ def test_receive_return_http_204_if_no_messages_in_database(self): | |||
self.assertEqual(response.content.decode(), '') | |||
assert len(ReceiveStatus.objects.filter(delivered=False)) == 0 | |||
|
|||
@freeze_time("2017-11-17 12:00:00") | |||
def test_receive_should_get_ack_after_task_to_compute_is_not_after_deadline(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give it a more sensible name: test_receive_should_return_ack_if_the_receive_queue_contains_only_force_report_and_its_past_deadline
.
The current name makes no sense because receive()
does not get anything. It only returns a message.
@@ -355,6 +355,56 @@ def test_receive_return_http_204_if_no_messages_in_database(self): | |||
self.assertEqual(response.content.decode(), '') | |||
assert len(ReceiveStatus.objects.filter(delivered=False)) == 0 | |||
|
|||
@freeze_time("2017-11-17 12:00:00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this inside the function. You only need to freeze time around the client.post()
call and I think this makes the test easier to undrstand because you can read the timestamps in order.
self.assertEqual(response.status_code, 200) | ||
self.assertIsInstance(decoded_ack_response, message.AckReportComputedTask) | ||
self.assertEqual(decoded_ack_response.task_to_compute.compute_task_def['task_id'], self.task_to_compute.compute_task_def['task_id']) # pylint: disable=no-member | ||
self.assertEqual(decoded_ack_response.task_to_compute.compute_task_def['deadline'], self.task_to_compute.compute_task_def['deadline']) # pylint: disable=no-member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You can compare
computed_task_def
as a whole. No need to compare the individual fields one by one. - You should actually check that the whole
TaskToCompute
message inside is unchanged and has the same signature. - You should compare
subtask_id
too. - You should check that the message in queue has been marked as delivered.
- You should check that the timestamp of the ack message is within the allowed range. It should not be for example too far in the past because the client won't be able to decode it and will discard it instead.
d9411b6
to
65eb1a0
Compare
Changes added. Ready for another review. |
65eb1a0
to
6a69222
Compare
6a69222
to
099a123
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ready to merge but pylint reports undefined-variable
errors. When you fix them I'll be able to merge it into master.
099a123
to
de3f980
Compare
de3f980
to
56f610d
Compare
Looks like the breakage reported by pylint was not from this branch but from #51 merged earlier. I have extracted the fix you added here into master. I did not notice this. If you see that it's master and not your branch that is broken, please tell me. master should always pass tests and have no warnings. |
Resolves #36 Added one missed test for AckReportComputedTask.