Skip to content

Commit e4fc020

Browse files
committed
Reduce the number of test workflow imports
1 parent 4f6ee15 commit e4fc020

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

bioblend/_tests/GalaxyTestBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GalaxyTestBase(unittest.TestCase):
2020
gi: GalaxyInstance
2121

2222
@classmethod
23-
def setUpClass(cls):
23+
def setUpClass(cls) -> None:
2424
galaxy_key = os.environ["BIOBLEND_GALAXY_API_KEY"]
2525
galaxy_url = os.environ["BIOBLEND_GALAXY_URL"]
2626
cls.gi = GalaxyInstance(url=galaxy_url, key=galaxy_key)

bioblend/_tests/TestGalaxyInvocations.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@
1313

1414

1515
class TestGalaxyInvocations(GalaxyTestBase.GalaxyTestBase):
16+
workflow_id: str
17+
pause_workflow_id: str
18+
19+
@classmethod
20+
def setUpClass(cls) -> None:
21+
super().setUpClass()
22+
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))
23+
cls.workflow_id = cls.gi.workflows.import_workflow_from_local_path(path)["id"]
24+
path = test_util.get_abspath(os.path.join("data", "test_workflow_pause.ga"))
25+
cls.pause_workflow_id = cls.gi.workflows.import_workflow_from_local_path(path)["id"]
26+
1627
def setUp(self):
1728
super().setUp()
18-
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))
19-
self.workflow_id = self.gi.workflows.import_workflow_from_local_path(path)["id"]
2029
self.history_id = self.gi.histories.create_history(name="TestGalaxyInvocations")["id"]
2130
self.dataset_id = self._test_dataset(self.history_id)
22-
path = test_util.get_abspath(os.path.join("data", "test_workflow_pause.ga"))
23-
self.pause_workflow_id = self.gi.workflows.import_workflow_from_local_path(path)["id"]
2431

2532
def tearDown(self):
2633
self.gi.histories.delete_history(self.history_id, purge=True)
@@ -42,16 +49,16 @@ def test_cancel_invocation(self):
4249
def test_get_invocations(self):
4350
invoc1 = self._invoke_workflow()
4451

45-
# Run the first workflow on another history
52+
# Run another workflow on the same history
53+
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))
54+
workflow2_id = self.gi.workflows.import_workflow_from_local_path(path)["id"]
4655
dataset = {"src": "hda", "id": self.dataset_id}
47-
hist2_id = self.gi.histories.create_history("hist2")["id"]
4856
invoc2 = self.gi.workflows.invoke_workflow(
49-
self.workflow_id, history_id=hist2_id, inputs={"Input 1": dataset, "Input 2": dataset}, inputs_by="name"
57+
workflow2_id, history_id=self.history_id, inputs={"Input 1": dataset, "Input 2": dataset}, inputs_by="name"
5058
)
5159

52-
# Run another workflow on the 2nd history
53-
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))
54-
workflow2_id = self.gi.workflows.import_workflow_from_local_path(path)["id"]
60+
# Run the second workflow on another history
61+
hist2_id = self.gi.histories.create_history("hist2")["id"]
5562
invoc3 = self.gi.workflows.invoke_workflow(
5663
workflow2_id, history_id=hist2_id, inputs={"Input 1": dataset, "Input 2": dataset}, inputs_by="name"
5764
)
@@ -60,14 +67,13 @@ def test_get_invocations(self):
6067
self.gi.invocations.wait_for_invocation(invoc["id"])
6168

6269
# Test filtering by workflow ID
63-
for wf_id, expected_invoc_num in {self.workflow_id: 2, workflow2_id: 1}.items():
64-
invocs = self.gi.invocations.get_invocations(workflow_id=wf_id)
65-
assert len(invocs) == expected_invoc_num
66-
for invoc in invocs:
67-
assert invoc["workflow_id"] == wf_id
70+
invocs = self.gi.invocations.get_invocations(workflow_id=workflow2_id)
71+
assert len(invocs) == 2
72+
for invoc in invocs:
73+
assert invoc["workflow_id"] == workflow2_id
6874

6975
# Test filtering by history ID
70-
for hist_id, expected_invoc_num in {self.history_id: 1, hist2_id: 2}.items():
76+
for hist_id, expected_invoc_num in {self.history_id: 2, hist2_id: 1}.items():
7177
invocs = self.gi.invocations.get_invocations(history_id=hist_id)
7278
assert len(invocs) == expected_invoc_num
7379
for invoc in invocs:

bioblend/_tests/TestGalaxyWorkflows.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ def test_invoke_workflow_parameters_normalized(self):
9393
@test_util.skip_unless_tool("cat")
9494
def test_cancelling_workflow_scheduling(self):
9595
path = test_util.get_abspath(os.path.join("data", "test_workflow_pause.ga"))
96-
workflow = self.gi.workflows.import_workflow_from_local_path(path)
97-
workflow_id = workflow["id"]
96+
workflow_id = self.gi.workflows.import_workflow_from_local_path(path)["id"]
9897
history_id = self.gi.histories.create_history(name="TestWorkflowState")["id"]
9998
dataset1_id = self._test_dataset(history_id)
10099

0 commit comments

Comments
 (0)