Skip to content

Commit

Permalink
Merge pull request #18521 from davelopez/24.0_fix_api_job_view_type
Browse files Browse the repository at this point in the history
[24.0] Fix view parameter type in Job index API
  • Loading branch information
mvdbeek authored Jul 10, 2024
2 parents 443640f + 6a62609 commit e77f928
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
)

ViewQueryParam: JobIndexViewEnum = Query(
default="collection",
default=JobIndexViewEnum.collection,
title="View",
description="Determines columns to return. Defaults to 'collection'.",
)
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/services/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def index(
# TODO: optimize if this crucial
if check_security_of_jobs and not security_check(trans, job.history, check_accessible=True):
raise exceptions.ItemAccessibilityException("Cannot access the request job objects.")
job_dict = job.to_dict(view, system_details=is_admin)
job_dict = job.to_dict(view.value, system_details=is_admin)
if view == JobIndexViewEnum.admin_job_list:
job_dict["decoded_job_id"] = job.id
if user_details:
Expand All @@ -97,7 +97,7 @@ def index(

def _check_nonadmin_access(
self,
view: str,
view: JobIndexViewEnum,
user_details: bool,
decoded_user_id: Optional[DecodedDatabaseIdField],
trans_user_id: Optional[int],
Expand Down
18 changes: 18 additions & 0 deletions lib/galaxy_test/api/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ def test_admin_job_list(self, history_id):
job = jobs[0]
self._assert_has_keys(job, "command_line", "external_id", "handler")

@pytest.mark.require_new_history
def test_job_list_collection_view(self, history_id):
self.__history_with_new_dataset(history_id)
jobs_response = self._get("jobs?view=collection")
self._assert_status_code_is_ok(jobs_response)
jobs = jobs_response.json()
job = jobs[0]
self._assert_has_keys(job, "id", "tool_id", "state")

@pytest.mark.require_new_history
def test_job_list_default_view(self, history_id):
self.__history_with_new_dataset(history_id)
jobs_response = self._get(f"jobs?history_id={history_id}")
self._assert_status_code_is_ok(jobs_response)
jobs = jobs_response.json()
job = jobs[0]
self._assert_has_keys(job, "id", "tool_id", "state")

@pytest.mark.require_new_history
def test_index_state_filter(self, history_id):
# Initial number of ok jobs
Expand Down

0 comments on commit e77f928

Please sign in to comment.