Using DecodedDatabaseIdField instead of Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField] for library_id and fix _create_dataset_in_folder_in_library function that is leading to failed tests

This commit is contained in:
Arash
2024-10-02 14:48:59 +02:00
parent b03ce07f82
commit 110e46781a
4 changed files with 9 additions and 13 deletions
-2
View File
@@ -310,8 +310,6 @@ class LibraryContentsPurgedResponse(LibraryContentsDeleteResponse):
purged: bool
AnyLibraryId = Union[DecodedDatabaseIdField, LibraryFolderDatabaseIdField]
AnyLibraryContentsShowResponse = Union[
LibraryContentsShowFolderResponse,
LibraryContentsShowDatasetResponse,
@@ -27,7 +27,6 @@ from galaxy.schema.library_contents import (
AnyLibraryContentsCreatePayload,
AnyLibraryContentsCreateResponse,
AnyLibraryContentsShowResponse,
AnyLibraryId,
LibraryContentsDeletePayload,
LibraryContentsDeleteResponse,
LibraryContentsFileCreatePayload,
@@ -74,7 +73,7 @@ class FastAPILibraryContents:
)
def index(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
trans: ProvidesUserContext = DependsOnTrans,
) -> LibraryContentsIndexListResponse:
"""This endpoint is deprecated. Please use GET /api/folders/{folder_id}/contents instead."""
@@ -88,7 +87,7 @@ class FastAPILibraryContents:
)
def show(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
id: MaybeLibraryFolderOrDatasetID,
trans: ProvidesUserContext = DependsOnTrans,
) -> AnyLibraryContentsShowResponse:
@@ -103,7 +102,7 @@ class FastAPILibraryContents:
)
def create_json(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
payload: AnyLibraryContentsCreatePayload,
trans: ProvidesHistoryContext = DependsOnTrans,
) -> AnyLibraryContentsCreateResponse:
@@ -119,7 +118,7 @@ class FastAPILibraryContents:
async def create_form(
self,
request: Request,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
payload: LibraryContentsFileCreatePayload = Depends(LibraryContentsCreateForm.as_form),
files: Optional[List[UploadFile]] = None,
trans: ProvidesHistoryContext = DependsOnTrans,
@@ -148,7 +147,7 @@ class FastAPILibraryContents:
)
def update(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
id: DecodedDatabaseIdField,
payload,
trans: ProvidesUserContext = DependsOnTrans,
@@ -163,7 +162,7 @@ class FastAPILibraryContents:
)
def delete(
self,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
id: DecodedDatabaseIdField,
payload: Optional[LibraryContentsDeletePayload] = Body(None),
trans: ProvidesHistoryContext = DependsOnTrans,
@@ -26,7 +26,6 @@ from galaxy.schema.library_contents import (
AnyLibraryContentsCreatePayload,
AnyLibraryContentsCreateResponse,
AnyLibraryContentsShowResponse,
AnyLibraryId,
LibraryContentsCreateDatasetCollectionResponse,
LibraryContentsCreateDatasetResponse,
LibraryContentsCreateFileListResponse,
@@ -78,7 +77,7 @@ class LibraryContentsService(ServiceBase, LibraryActions, UsesLibraryMixinItems,
def index(
self,
trans: ProvidesUserContext,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
) -> LibraryContentsIndexListResponse:
"""Return a list of library files and folders."""
rval: List[Union[LibraryContentsIndexFolderResponse, LibraryContentsIndexDatasetResponse]] = []
@@ -124,7 +123,7 @@ class LibraryContentsService(ServiceBase, LibraryActions, UsesLibraryMixinItems,
def create(
self,
trans: ProvidesHistoryContext,
library_id: AnyLibraryId,
library_id: DecodedDatabaseIdField,
payload: AnyLibraryContentsCreatePayload,
) -> AnyLibraryContentsCreateResponse:
"""Create a new library file or folder."""
+1 -1
View File
@@ -605,6 +605,6 @@ class TestLibrariesApi(ApiTestCase):
history_id = self.dataset_populator.new_history()
hda_id = self.dataset_populator.new_dataset(history_id, content=content, wait=wait)["id"]
payload = {"from_hda_id": hda_id, "create_type": "file", "folder_id": folder_id}
ld = self._post(f"libraries/{folder_id}/contents", payload, json=True)
ld = self._post(f"libraries/{library['id']}/contents", payload, json=True)
ld.raise_for_status()
return ld