Skip to content
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

Merged
merged 1 commit into from
Jan 22, 2018

Conversation

kbeker
Copy link
Contributor

@kbeker kbeker commented Jan 18, 2018

Resolves #36 Added one missed test for AckReportComputedTask.

@kbeker kbeker changed the title core.test_core_views: Add test to get ack if force is not after deadline Add missing test for AckReportComputedTask Jan 18, 2018
)
message_timestamp = datetime.datetime.now(timezone.utc)
new_message = Message(
type = self.force_golem_data.__class__.__name__,
Copy link
Contributor

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):
Copy link
Contributor

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")
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You can compare computed_task_def as a whole. No need to compare the individual fields one by one.
  2. You should actually check that the whole TaskToCompute message inside is unchanged and has the same signature.
  3. You should compare subtask_id too.
  4. You should check that the message in queue has been marked as delivered.
  5. 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.

@kbeker kbeker force-pushed the fix-add-missing-test-for-ack-response branch 2 times, most recently from d9411b6 to 65eb1a0 Compare January 18, 2018 16:47
@kbeker
Copy link
Contributor Author

kbeker commented Jan 18, 2018

Changes added. Ready for another review.

@kbeker kbeker force-pushed the fix-add-missing-test-for-ack-response branch from 65eb1a0 to 6a69222 Compare January 19, 2018 11:20
@cameel cameel force-pushed the fix-add-missing-test-for-ack-response branch from 6a69222 to 099a123 Compare January 19, 2018 14:52
Copy link
Contributor

@cameel cameel left a 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.

@kbeker kbeker force-pushed the fix-add-missing-test-for-ack-response branch from 099a123 to de3f980 Compare January 19, 2018 15:30
@cameel cameel force-pushed the fix-add-missing-test-for-ack-response branch from de3f980 to 56f610d Compare January 22, 2018 08:52
@cameel
Copy link
Contributor

cameel commented Jan 22, 2018

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.

@cameel cameel merged commit 56f610d into master Jan 22, 2018
@cameel cameel deleted the fix-add-missing-test-for-ack-response branch January 22, 2018 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants