Files
galaxy/test/integration/test_workflow_sync.py
T
Nicola Soranzo 30f60493c3 Format Python code with black 23.1.0
with manual fixes to 3 files to make them compatible with black 22.12.0 .

We need to keep black pinned at `<23` until we vendorise `packaging`, since
the new version of black depends on `packaging >=22.0` which is the version
where `LegacyVersion` (which we use for tool lineages) was removed.
2023-02-01 23:51:03 +00:00

54 lines
2.0 KiB
Python

"""Integration tests for workflow syncing."""
import json
import os
import yaml
from galaxy_test.base.populators import (
DatasetPopulator,
WorkflowPopulator,
)
from galaxy_test.base.workflow_fixtures import WORKFLOW_SIMPLE_CAT_TWICE
from galaxy_test.driver import integration_util
class TestWorkflowSync(integration_util.IntegrationTestCase):
framework_tool_and_types = True
require_admin_user = True
def setUp(self):
super().setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, config):
super().handle_galaxy_config_kwds(config)
cls.workflow_directory = cls._test_driver.mkdtemp()
def test_sync_format2(self):
workflow_path = self._write_workflow_content("workflow.yml", WORKFLOW_SIMPLE_CAT_TWICE)
workflow_id = self.workflow_populator.import_workflow_from_path(workflow_path)
with self.workflow_populator.export_for_update(workflow_id) as workflow_object:
workflow_object["annotation"] = "new annotation"
with open(workflow_path) as f:
data = yaml.safe_load(f)
assert data["doc"] == "new annotation"
def test_sync_ga(self):
workflow_json = self.workflow_populator.load_workflow("synctest")
workflow_path = self._write_workflow_content("workflow.ga", json.dumps(workflow_json))
workflow_id = self.workflow_populator.import_workflow_from_path(workflow_path)
with self.workflow_populator.export_for_update(workflow_id) as workflow_object:
workflow_object["annotation"] = "new annotation"
with open(workflow_path) as f:
data = json.load(f)
assert data["annotation"] == "new annotation"
def _write_workflow_content(self, filename, content):
workflow_path = os.path.join(self.workflow_directory, filename)
with open(workflow_path, "w") as f:
f.write(content)
return workflow_path