Commit 35469b11 authored by payno's avatar payno
Browse files

[ewoks] add test to insure two default graph can be converted to ewoks graph without lost

parent d5dbfb70
from ewoksorange.owsconvert import ows_to_ewoks, ewoks_to_ows
from ewokscore.graph import TaskGraph
from est.core.utils import DownloadDataset
import unittest
import tempfile
import shutil
import os
class TestOrangeGraph(unittest.TestCase):
def setUp(self) -> None:
self.folder = tempfile.mkdtemp()
file_pymca = "ows_files/example_pymca.ows"
file_larch = "ows_files/example_larch.ows"
for file_ in (file_larch, file_pymca):
DownloadDataset(dataset=file_, output_folder=self.folder, timeout=2.0)
self._example_pymca_ows = os.path.join(self.folder, "example_pymca.ows")
self._example_larch_ows = os.path.join(self.folder, "example_larch.ows")
assert os.path.exists(self._example_larch_ows)
assert os.path.exists(self._example_pymca_ows)
def tearDown(self) -> None:
shutil.rmtree(self.folder)
def test_orange_graph_to_ewo_graph_pymca(self):
"""test conversion of a workflow based on pymca to ewoks graph"""
graph = ows_to_ewoks(self._example_pymca_ows)
self.assertTrue(isinstance(graph, TaskGraph))
self.assertEqual(len(graph.start_nodes()), 1)
self.assertTrue("input" in graph.start_nodes())
for node in (
"input",
"output",
"normalization",
"exafs",
"k weight",
"fourier transform",
):
self.assertTrue(node in graph.graph.nodes())
self.assertEqual(len(graph.graph.edges), 5)
def test_orange_graph_to_ewo_graph_larch(self):
"""test conversion of a workflow based on pymca to ewoks graph"""
graph = ows_to_ewoks(self._example_larch_ows)
self.assertTrue(isinstance(graph, TaskGraph))
self.assertEqual(len(graph.start_nodes()), 1)
self.assertTrue("input" in graph.start_nodes())
for node in ("input", "output", "pre edge", "autobk", "xftf"):
self.assertTrue(node in graph.graph.nodes())
self.assertEqual(len(graph.graph.edges), 4)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment