diff --git a/lib/galaxy/webapps/galaxy/api/datasets.py b/lib/galaxy/webapps/galaxy/api/datasets.py index 2ef05428573..ce7a0a2efd1 100644 --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -47,7 +47,7 @@ from galaxy.webapps.galaxy.api.common import ( ) from galaxy.webapps.galaxy.services.datasets import ( ConvertedDatasetsMap, - DatasetInheritanceChainEntry, + DatasetInheritanceChain, DatasetsService, DatasetStorageDetails, DatasetTextContentDetails, @@ -122,7 +122,7 @@ class FastAPIDatasets: trans=DependsOnTrans, dataset_id: EncodedDatabaseIdField = DatasetIDPathParam, hda_ldda: DatasetSourceType = DatasetSourceQueryParam, - ) -> List[DatasetInheritanceChainEntry]: + ) -> DatasetInheritanceChain: return self.service.show_inheritance_chain(trans, dataset_id, hda_ldda) @router.get( diff --git a/lib/galaxy/webapps/galaxy/services/datasets.py b/lib/galaxy/webapps/galaxy/services/datasets.py index 7295078771f..39c155791e4 100644 --- a/lib/galaxy/webapps/galaxy/services/datasets.py +++ b/lib/galaxy/webapps/galaxy/services/datasets.py @@ -104,6 +104,13 @@ class DatasetInheritanceChainEntry(Model): ) +class DatasetInheritanceChain(Model): + __root__: List[DatasetInheritanceChainEntry] = Field( + default=[], + title="Dataset inheritance chain", + ) + + class ExtraFilesEntryClass(str, Enum): Directory = "Directory" File = "File" @@ -310,7 +317,7 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin): trans: ProvidesHistoryContext, dataset_id: EncodedDatabaseIdField, hda_ldda: DatasetSourceType = DatasetSourceType.hda, - ) -> List[DatasetInheritanceChainEntry]: + ) -> DatasetInheritanceChain: """ Display inheritance chain for the given dataset. """ @@ -321,7 +328,7 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin): for dep in inherit_chain: result.append(DatasetInheritanceChainEntry(name=f"{dep[0].name}", dep=dep[1])) - return result + return DatasetInheritanceChain(__root__=result) def update_permissions( self, diff --git a/lib/galaxy_test/api/test_history_contents.py b/lib/galaxy_test/api/test_history_contents.py index d1d83b7ab04..6cc73032a39 100644 --- a/lib/galaxy_test/api/test_history_contents.py +++ b/lib/galaxy_test/api/test_history_contents.py @@ -163,7 +163,7 @@ class HistoryContentsApiTestCase(ApiTestCase): self._assert_status_code_is(show_response, 200) self.__assert_matches_hda(hda1, show_response.json()) - def test_hda_copy(self): + def _create_copy(self): hda1 = self.dataset_populator.new_dataset(self.history_id) create_data = dict( source='hda', @@ -173,7 +173,18 @@ class HistoryContentsApiTestCase(ApiTestCase): assert self.__count_contents(second_history_id) == 0 create_response = self._post(f"histories/{second_history_id}/contents", create_data, json=True) self._assert_status_code_is(create_response, 200) - assert self.__count_contents(second_history_id) == 1 + return create_response.json() + + def test_hda_copy(self): + response = self._create_copy() + assert self.__count_contents(response['history_id']) == 1 + + def test_inheritance_chain(self): + response = self._create_copy() + inheritance_chain_response = self._get(f"datasets/{response['id']}/inheritance_chain") + self._assert_status_code_is_ok(inheritance_chain_response) + inheritance_chain = inheritance_chain_response.json() + assert len(inheritance_chain) == 1 def test_library_copy(self): ld = self.library_populator.new_library_dataset("lda_test_library")