mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 00:44:55 +08:00
Merge pull request #12456 from davelopez/fix_update_batch
Fix history contents API update batch with collections
This commit is contained in:
@@ -634,7 +634,12 @@ class UpdateHDCAPayload(HDCADetailed):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateHistoryContentsBatchPayload(Model):
|
||||
class UpdateHistoryContentsBatchPayload(BaseModel):
|
||||
class Config:
|
||||
use_enum_values = True # when using .dict()
|
||||
allow_population_by_field_name = True
|
||||
extra = Extra.allow # Allow any additional field
|
||||
|
||||
items: List[Union[UpdateHDAPayload, UpdateHDCAPayload]] = Field(
|
||||
...,
|
||||
title="Items",
|
||||
|
||||
@@ -583,7 +583,7 @@ class HistoriesContentsService(ServiceBase):
|
||||
hda, user=trans.user, trans=trans, **serialization_params
|
||||
))
|
||||
for hdca_id in hdca_ids:
|
||||
self.__update_dataset_collection(trans, hdca_id, payload)
|
||||
self.__update_dataset_collection(trans, hdca_id, payload.dict(exclude_defaults=True))
|
||||
dataset_collection_instance = self.__get_accessible_collection(trans, hdca_id)
|
||||
rval.append(self.__collection_dict(trans, dataset_collection_instance, view="summary"))
|
||||
return rval
|
||||
|
||||
@@ -429,13 +429,7 @@ class HistoryContentsApiTestCase(ApiTestCase):
|
||||
assert not datasets[1]["visible"]
|
||||
|
||||
def test_update_dataset_collection(self):
|
||||
payload = self.dataset_collection_populator.create_pair_payload(
|
||||
self.history_id,
|
||||
type="dataset_collection"
|
||||
)
|
||||
dataset_collection_response = self._post(f"histories/{self.history_id}/contents", payload)
|
||||
self._assert_status_code_is(dataset_collection_response, 200)
|
||||
hdca = dataset_collection_response.json()
|
||||
hdca = self._create_pair_collection()
|
||||
update_url = self._api_url(f"histories/{self.history_id}/contents/dataset_collections/{hdca['id']}", use_key=True)
|
||||
# Awkward json.dumps required here because of https://trello.com/c/CQwmCeG6
|
||||
body = json.dumps(dict(name="newnameforpair"))
|
||||
@@ -444,6 +438,30 @@ class HistoryContentsApiTestCase(ApiTestCase):
|
||||
show_response = self.__show(hdca)
|
||||
assert str(show_response.json()["name"]) == "newnameforpair"
|
||||
|
||||
def test_update_batch_dataset_collection(self):
|
||||
hdca = self._create_pair_collection()
|
||||
body = {
|
||||
"items": [{
|
||||
"history_content_type": "dataset_collection",
|
||||
"id": hdca["id"]
|
||||
}],
|
||||
"name": "newnameforpair"
|
||||
}
|
||||
update_response = self._put(f"histories/{self.history_id}/contents", data=body, json=True)
|
||||
self._assert_status_code_is(update_response, 200)
|
||||
show_response = self.__show(hdca)
|
||||
assert str(show_response.json()["name"]) == "newnameforpair"
|
||||
|
||||
def _create_pair_collection(self):
|
||||
payload = self.dataset_collection_populator.create_pair_payload(
|
||||
self.history_id,
|
||||
type="dataset_collection"
|
||||
)
|
||||
dataset_collection_response = self._post(f"histories/{self.history_id}/contents", payload)
|
||||
self._assert_status_code_is(dataset_collection_response, 200)
|
||||
hdca = dataset_collection_response.json()
|
||||
return hdca
|
||||
|
||||
def test_hdca_copy(self):
|
||||
hdca = self.dataset_collection_populator.create_pair_in_history(self.history_id).json()
|
||||
hdca_id = hdca["id"]
|
||||
|
||||
Reference in New Issue
Block a user