From 8317e93b8b887eac931695f427037125d0b5bd2e Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Fri, 8 Mar 2024 15:07:08 +0100 Subject: [PATCH] transmit output_dir param, add test to prevent regression --- src/workflow.py | 9 ++++++++- tests/test_cli.py | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/test_cli.py diff --git a/src/workflow.py b/src/workflow.py index 5961369..3e04232 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -6,6 +6,7 @@ from . import constant import os import re import json +from pathlib import Path class Workflow: @@ -14,7 +15,13 @@ class Workflow: license = None, creativeWorkStatus = None, authors = None, version = None, keywords = None, producer = None, publisher = None): - self.nextflow_file = Nextflow_File(file, duplicate = duplicate, display_info = display_info) + self.nextflow_file = Nextflow_File( + file, + duplicate=duplicate, + display_info=display_info, + output_dir=output_dir + ) + self.output_dir = Path(output_dir) self.rocrate = None self.name = name self.datePublished = datePublished diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..04db2ce --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,20 @@ +import pathlib +import unittest +from tempfile import TemporaryDirectory + +from bioflow_insight_cli.main import cli + + +class TestCall(unittest.TestCase): + + def test_cli_works(self): + cli("./wf_test/main.nf", render_graphs=True) + cli("./wf_test/main.nf", render_graphs=False) + + def test_cli_output_considered(self): + with TemporaryDirectory() as my_temp_dir: + my_results = pathlib.Path(my_temp_dir) / "my_results" + self.assertFalse(my_results.exists()) + cli("./wf_test/main.nf", render_graphs=False, output_dir=str(my_results)) + self.assertTrue(my_results.exists(), "Results should be there, output_dir not taken into account") + -- GitLab