Skip to content

Commit

Permalink
Adapt API tests to use JSON payload
Browse files Browse the repository at this point in the history
See galaxyproject#12152 for details.
  • Loading branch information
davelopez committed Oct 27, 2021
1 parent c5f8510 commit fc6f5aa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/verify/interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def _create_collection(self, history_id, collection_def):
collection_type=collection_def.collection_type,
history_id=history_id,
)
return self._post("dataset_collections", data=create_payload).json()["id"]
return self._post("dataset_collections", data=create_payload, json=True).json()["id"]

def _element_identifiers(self, collection_def):
element_identifiers = []
Expand Down
26 changes: 13 additions & 13 deletions lib/galaxy_test/api/test_dataset_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_create_pair_from_history(self):
self.history_id,
instance_type="history",
)
create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
dataset_collection = self._check_create_response(create_response)
returned_datasets = dataset_collection["elements"]
assert len(returned_datasets) == 2, dataset_collection
Expand All @@ -33,11 +33,11 @@ def test_create_list_from_history(self):
payload = dict(
instance_type="history",
history_id=self.history_id,
element_identifiers=json.dumps(element_identifiers),
element_identifiers=element_identifiers,
collection_type="list",
)

create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
dataset_collection = self._check_create_response(create_response)
returned_datasets = dataset_collection["elements"]
assert len(returned_datasets) == 3, dataset_collection
Expand All @@ -47,7 +47,7 @@ def test_create_list_of_existing_pairs(self):
self.history_id,
instance_type="history",
)
pair_create_response = self._post("dataset_collections", pair_payload)
pair_create_response = self._post("dataset_collections", pair_payload, json=True)
dataset_collection = self._check_create_response(pair_create_response)
hdca_id = dataset_collection["id"]

Expand All @@ -58,10 +58,10 @@ def test_create_list_of_existing_pairs(self):
payload = dict(
instance_type="history",
history_id=self.history_id,
element_identifiers=json.dumps(element_identifiers),
element_identifiers=element_identifiers,
collection_type="list",
)
create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
dataset_collection = self._check_create_response(create_response)
returned_collections = dataset_collection["elements"]
assert len(returned_collections) == 1, dataset_collection
Expand All @@ -73,9 +73,9 @@ def test_create_list_of_new_pairs(self):
instance_type="history",
history_id=self.history_id,
name="a nested collection",
element_identifiers=json.dumps(identifiers),
element_identifiers=identifiers,
)
create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
dataset_collection = self._check_create_response(create_response)
assert dataset_collection["collection_type"] == "list:paired"
assert dataset_collection["name"] == "a nested collection"
Expand Down Expand Up @@ -169,10 +169,10 @@ def test_hda_security(self):
payload = dict(
instance_type="history",
history_id=history_id,
element_identifiers=json.dumps(element_identifiers),
element_identifiers=element_identifiers,
collection_type="paired",
)
create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
self._assert_status_code_is(create_response, 403)

def test_enforces_unique_names(self):
Expand All @@ -181,11 +181,11 @@ def test_enforces_unique_names(self):
payload = dict(
instance_type="history",
history_id=self.history_id,
element_identifiers=json.dumps(element_identifiers),
element_identifiers=element_identifiers,
collection_type="list",
)

create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
self._assert_status_code_is(create_response, 400)

def test_upload_collection(self):
Expand Down Expand Up @@ -488,7 +488,7 @@ def _compare_collection_contents_elements(self, contents_elements, hdca_elements
def _create_collection_contents_pair(self):
# Create a simple collection, return hdca and contents_url
payload = self.dataset_collection_populator.create_pair_payload(self.history_id, instance_type="history")
create_response = self._post("dataset_collections", payload)
create_response = self._post("dataset_collections", payload, json=True)
hdca = self._check_create_response(create_response)
root_contents_url = self._get_contents_url_for_hdca(hdca)
return hdca, root_contents_url
Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy_test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ def create_nested_collection(self, history_id, collection_type, name=None, colle
payload = dict(
instance_type="history",
history_id=history_id,
element_identifiers=json.dumps(element_identifiers),
element_identifiers=element_identifiers,
collection_type=collection_type,
name=name,
)
Expand Down Expand Up @@ -1594,7 +1594,7 @@ def __create_payload_collection(self, history_id, identifiers_func, collection_t
del kwds["contents"]

if "element_identifiers" not in kwds:
kwds["element_identifiers"] = json.dumps(identifiers_func(history_id, contents=contents))
kwds["element_identifiers"] = identifiers_func(history_id, contents=contents)

if "name" not in kwds:
kwds["name"] = "Test Dataset Collection"
Expand Down Expand Up @@ -1672,7 +1672,7 @@ def __init__(self, galaxy_interactor: ApiTestInteractor):
self.dataset_populator = DatasetPopulator(galaxy_interactor)

def _create_collection(self, payload: dict) -> Response:
create_response = self.galaxy_interactor.post("dataset_collections", data=payload)
create_response = self.galaxy_interactor.post("dataset_collections", data=payload, json=True)
return create_response


Expand Down Expand Up @@ -1861,7 +1861,7 @@ def __init__(self, gi):
self.dataset_collection_populator = GiDatasetCollectionPopulator(gi)

def _create_collection(self, payload):
create_response = self._post("dataset_collections", data=payload)
create_response = self._post("dataset_collections", data=payload, json=True)
return create_response


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy_test/selenium/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def __init__(self, selenium_context: GalaxySeleniumContext):
self.dataset_populator = SeleniumSessionDatasetPopulator(selenium_context)

def _create_collection(self, payload: dict) -> Response:
create_response = self._post("dataset_collections", data=payload)
create_response = self._post("dataset_collections", data=payload, json=True)
return create_response


Expand Down

0 comments on commit fc6f5aa

Please sign in to comment.