Unverified Commit e77f9289 authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #18521 from davelopez/24.0_fix_api_job_view_type

[24.0] Fix view parameter type in Job index API
parents 443640fb 6a62609e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ UserIdQueryParam: Optional[DecodedDatabaseIdField] = Query(
)

ViewQueryParam: JobIndexViewEnum = Query(
    default="collection",
    default=JobIndexViewEnum.collection,
    title="View",
    description="Determines columns to return. Defaults to 'collection'.",
)
+2 −2
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ class JobsService(ServiceBase):
            # 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:
@@ -97,7 +97,7 @@ class JobsService(ServiceBase):

    def _check_nonadmin_access(
        self,
        view: str,
        view: JobIndexViewEnum,
        user_details: bool,
        decoded_user_id: Optional[DecodedDatabaseIdField],
        trans_user_id: Optional[int],
+18 −0
Original line number Diff line number Diff line
@@ -62,6 +62,24 @@ class TestJobsApi(ApiTestCase, TestsTools):
        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