-
Notifications
You must be signed in to change notification settings - Fork 966
/
test_tool_data_delete.py
70 lines (56 loc) · 2.79 KB
/
test_tool_data_delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Integration tests for tool data tables that require special configuration.
This file checks API endpoints that require different non-default Galaxy
configuration options, in particular the DELETE endpoint.
To avoid altering the '.loc' files in test/functional/tool-data, these files are
copied to a temp directory and then used by the integration test.
"""
import json
import os
import shutil
import time
from requests import delete
from galaxy_test.base.populators import DatasetPopulator
from galaxy_test.driver import integration_util
THIS_DIR = os.path.dirname(__file__)
SOURCE_TOOL_DATA_DIRECTORY = os.path.join(THIS_DIR, os.pardir, "functional", "tool-data")
class AdminToolDataIntegrationTestCase(integration_util.IntegrationTestCase):
require_admin_user = True
def setUp(self):
super().setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
@classmethod
def configure_temp_tool_data_dir(cls):
cls.temp_tool_data_dir = cls.temp_config_dir("tool-data")
cls.temp_tool_data_tables_file = os.path.join(cls.temp_tool_data_dir, "sample_tool_data_tables.xml")
shutil.copytree(SOURCE_TOOL_DATA_DIRECTORY, cls.temp_tool_data_dir)
cls._test_driver.temp_directories.append(cls.temp_tool_data_dir)
@classmethod
def handle_galaxy_config_kwds(cls, config):
cls.configure_temp_tool_data_dir()
config["tool_data_path"] = cls.temp_tool_data_dir
config["tool_data_table_config_path"] = cls.temp_tool_data_tables_file
def test_admin_delete_data_table_entry(self):
show_response = self._get("tool_data/testbeta")
original_count = len(show_response.json()["fields"])
history_id = self.dataset_populator.new_history()
payload = self.dataset_populator.run_tool_payload(
tool_id="data_manager",
inputs={"ignored_value": "moo"},
history_id=history_id,
)
create_response = self._post("tools", data=payload)
create_response.raise_for_status()
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
time.sleep(2)
show_response = self._get("tool_data/testbeta")
updated_fields = show_response.json()["fields"]
self.assertEquals(len(updated_fields), original_count + 1)
new_field = updated_fields[-1]
url = self._api_url(f"tool_data/testbeta?key={self.galaxy_interactor.api_key}")
delete_response = delete(url, data=json.dumps({"values": "\t".join(new_field)}), headers={'Content-Type': 'application/json'})
delete_response.raise_for_status()
time.sleep(2)
show_response = self._get("tool_data/testbeta")
show_response.raise_for_status()
updated_fields = show_response.json()["fields"]
assert len(updated_fields) == original_count