-
Notifications
You must be signed in to change notification settings - Fork 58
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
Fix for task id as valid UUID #3744
base: main
Are you sure you want to change the base?
Changes from all commits
d76b47e
914c30e
24244f8
5530223
27f2678
5e6282e
8fcd923
cfb05d3
d268910
9495262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ def get_context_data(self, **kwargs): | |
class NormalizerTaskJSONView(TaskDetailView): | ||
task_type = "normalizer" | ||
plugin_type = "normalizer" | ||
template_name = "tasks/normalizer_task_detail.html" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My test failed on this part, because it was missing the template name |
||
|
||
def get(self, request, *args, **kwargs) -> JsonResponse | HttpResponse: | ||
task = self.get_json_task_details() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from rocky.scheduler import SchedulerConnectError, SchedulerTooManyRequestError, SchedulerValidationError | ||
from rocky.views.task_detail import NormalizerTaskJSONView | ||
from rocky.views.tasks import BoefjesTaskListView | ||
from tests.conftest import setup_request | ||
|
||
|
@@ -37,3 +38,27 @@ def test_tasks_view_too_many_requests_error(rf, client_member, mock_scheduler): | |
list(request._messages)[0].message | ||
== "Scheduler is receiving too many requests. Increase SCHEDULER_PQ_MAXSIZE or wait for task to finish." | ||
) | ||
|
||
|
||
def test_get_task_details_json_bad_task_id(rf, client_member, mock_scheduler): | ||
request = setup_request(rf.get("normalizer_task_view"), client_member.user) | ||
|
||
response = NormalizerTaskJSONView.as_view()( | ||
request, organization_code=client_member.organization.code, task_id="/delete" | ||
) | ||
|
||
assert response.status_code == 200 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably return a 404, not a 200. |
||
|
||
assert list(request._messages)[0].message == "Task could not be found." | ||
|
||
|
||
def test_reschedule_task_bad_task_id(rf, client_member, mock_bytes_client, mock_scheduler): | ||
request = setup_request( | ||
rf.post("task_list", {"action": "reschedule_task", "task_id": "/delete"}), client_member.user | ||
) | ||
|
||
response = BoefjesTaskListView.as_view()(request, organization_code=client_member.organization.code) | ||
|
||
assert response.status_code == 200 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably return a 404, not a 200. |
||
|
||
assert list(request._messages)[0].message == "Task could not be found." |
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.
this is automatically removed and is not part of this PR. None is already a default return value.