Files
galaxy/test/integration/test_workflow_sync.py
T
John Chilton 45019c3fbd Move galaxy testing utilities into more sane package structure.
Split test/base into lib/galaxy_test/base and lib/galaxy_test/driver. Dividing things on whether they import galaxy-app code or not - with the goal of a galaxy-test-base package that doesn't depend on galaxy-app and a galaxy-test-driver package that does.

I've been refactoring around this division for a long time. Certain tests (namely the integration tests) always need to bootstrap Galaxy - but the API tests and the Selenium tests should be installable and runnable without Galaxy in the Python environment. So future galaxy-test-api and galaxy-test-selenium packages should have only an optional dependency on galaxy-test-driver.

Properly sturcturing these namespaces is a precursor for real packages on PyPI, clean separation of the tool shed testing code, and cleans up all the flake8 noqa hacks in test/.
2019-11-12 09:03:06 -05: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 WorkflowSyncTestCase(integration_util.IntegrationTestCase):
framework_tool_and_types = True
require_admin_user = True
def setUp(self):
super(WorkflowSyncTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)
@classmethod
def handle_galaxy_config_kwds(cls, 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, "r") 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, "r") 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