Skip to content
Snippets Groups Projects
Commit 62c283c7 authored by mjbonifa's avatar mjbonifa
Browse files

changed acmc.py to main.py, convention for cli tool

parent 74fe2c40
Branches
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from pathlib import Path ...@@ -8,7 +8,7 @@ from pathlib import Path
import trud import trud
import omop import omop
import phen import phen
import acmc import main
# setup logging # setup logging
from logging_config import setup_logger from logging_config import setup_logger
...@@ -35,29 +35,29 @@ def logger(): ...@@ -35,29 +35,29 @@ def logger():
def test_phen_init_local_default(tmp_dir, monkeypatch, caplog): def test_phen_init_local_default(tmp_dir, monkeypatch, caplog):
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "init"]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "init"])
# Mock input() to return "yes" to the question about reinitialising the directory # Mock input() to return "yes" to the question about reinitialising the directory
monkeypatch.setattr("builtins.input", lambda _: "y") monkeypatch.setattr("builtins.input", lambda _: "y")
acmc.main() main.main()
assert "Phenotype initialised successfully" in caplog.text assert "Phenotype initialised successfully" in caplog.text
def test_phen_init_local_specified(tmp_dir, monkeypatch, caplog): def test_phen_init_local_specified(tmp_dir, monkeypatch, caplog):
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
phen_path = tmp_dir / "phen" phen_path = tmp_dir / "phen"
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "init", "-d", str(phen_path.resolve())]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "init", "-d", str(phen_path.resolve())])
# Mock input() to return "yes" to the question about reinitialising the directory # Mock input() to return "yes" to the question about reinitialising the directory
monkeypatch.setattr("builtins.input", lambda _: "y") monkeypatch.setattr("builtins.input", lambda _: "y")
acmc.main() main.main()
assert "Phenotype initialised successfully" in caplog.text assert "Phenotype initialised successfully" in caplog.text
def test_phen_workflow(tmp_dir, monkeypatch, caplog): def test_phen_workflow(tmp_dir, monkeypatch, caplog):
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
phen_path = tmp_dir / "phen" phen_path = tmp_dir / "phen"
phen_path = phen_path.resolve() phen_path = phen_path.resolve()
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "init", "-d", str(phen_path.resolve())]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "init", "-d", str(phen_path.resolve())])
# Mock input() to return "yes" to the question about reinitialising the directory # Mock input() to return "yes" to the question about reinitialising the directory
monkeypatch.setattr("builtins.input", lambda _: "y") monkeypatch.setattr("builtins.input", lambda _: "y")
acmc.main() main.main()
assert "Phenotype initialised successfully" in caplog.text assert "Phenotype initialised successfully" in caplog.text
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
...@@ -74,31 +74,31 @@ def test_phen_workflow(tmp_dir, monkeypatch, caplog): ...@@ -74,31 +74,31 @@ def test_phen_workflow(tmp_dir, monkeypatch, caplog):
shutil.copy(source, destination) shutil.copy(source, destination)
shutil.copy( phen_path / 'config1.json', phen_path / 'config.json') shutil.copy( phen_path / 'config1.json', phen_path / 'config.json')
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "validate", "-d", str(phen_path.resolve())]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "validate", "-d", str(phen_path.resolve())])
acmc.main() main.main()
assert "Phenotype validated successfully" in caplog.text assert "Phenotype validated successfully" in caplog.text
# map phenotype # map phenotype
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "map", "-d", str(phen_path.resolve()), "-t", "read2", "-tr", "-ve"]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "map", "-d", str(phen_path.resolve()), "-t", "read2", "-tr", "-ve"])
acmc.main() main.main()
assert "Phenotype processed successfully" in caplog.text assert "Phenotype processed successfully" in caplog.text
# publish phenotype # publish phenotype
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "publish", "-d", str(phen_path.resolve())]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "publish", "-d", str(phen_path.resolve())])
acmc.main() main.main()
assert "Phenotype published successfully" in caplog.text assert "Phenotype published successfully" in caplog.text
# copy phenotype' # copy phenotype'
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "copy", "-d", str(phen_path.resolve()), "-td", str(tmp_dir.resolve()), "-v", "v1.0.3"]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "copy", "-d", str(phen_path.resolve()), "-td", str(tmp_dir.resolve()), "-v", "v1.0.3"])
acmc.main() main.main()
assert "Phenotype copied successfully" in caplog.text assert "Phenotype copied successfully" in caplog.text
# diff phenotype # diff phenotype
with caplog.at_level(logging.DEBUG): with caplog.at_level(logging.DEBUG):
old_path = tmp_dir / "v1.0.3" old_path = tmp_dir / "v1.0.3"
monkeypatch.setattr(sys, "argv", ["acmc.py", "phen", "diff", "-d", str(phen_path.resolve()), "-old", str(old_path.resolve())]) monkeypatch.setattr(sys, "argv", ["main.py", "phen", "diff", "-d", str(phen_path.resolve()), "-old", str(old_path.resolve())])
acmc.main() main.main()
assert "Phenotypes diff'd successfully" in caplog.text assert "Phenotypes diff'd successfully" in caplog.text
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment