Skip to content
Snippets Groups Projects
Select Git revision
  • 6e07a95e79f5ecb0d932f9830142f53d0c16b6f7
  • master default protected
2 results

Controller.java

Blame
  • test_commands.py 2.80 KiB
    import pytest
    import argparse
    from unittest.mock import patch, MagicMock
    
    import trud
    import omop
    import phen
    from pathlib import Path
    from acmc import trud_install, omop_install, omop_clear, omop_delete, phen_init, phen_validate, phen_map, phen_publish, phen_copy, phen_diff
    
    def test_trud_install():
        with patch("trud.install") as mock_install:
            args = argparse.Namespace(api_key="test_key")
            trud_install(args)
            mock_install.assert_called_once_with("test_key")
    
    def test_omop_install():
        with patch("omop.install") as mock_install:
            args = argparse.Namespace(omop_folder="/path/to/omop")
            omop_install(args)
            mock_install.assert_called_once_with(omop.OMOP_DB_PATH, "/path/to/omop")
    
    def test_omop_clear():
        with patch("omop.clear") as mock_clear:
            args = argparse.Namespace()
            omop_clear(args)
            mock_clear.assert_called_once_with(omop.OMOP_DB_PATH)
    
    def test_omop_delete():
        with patch("omop.delete") as mock_delete:
            args = argparse.Namespace()
            omop_delete(args)
            mock_delete.assert_called_once_with(omop.OMOP_DB_PATH)
    
    def test_phen_init():
        with patch("phen.init") as mock_init:
            args = argparse.Namespace(phen_dir="/path/to/phen")
            phen_init(args)
            mock_init.assert_called_once_with("/path/to/phen")
    
    def test_phen_validate():
        with patch("phen.validate") as mock_validate:
            args = argparse.Namespace(phen_dir="/path/to/phen")
            phen_validate(args)
            mock_validate.assert_called_once_with("/path/to/phen")
    
    def test_phen_map():
        with patch("phen.map") as mock_map:
            args = argparse.Namespace(phen_dir="/path/to/phen", target_coding="icd10_code", translate=True, verify=True)
            phen_map(args)
            mock_map.assert_called_once_with("/path/to/phen", "icd10_code", True, True)
    
    def test_phen_publish():
        with patch("phen.publish") as mock_publish:
            args = argparse.Namespace(phen_dir="/path/to/phen")
            phen_publish(args)
            mock_publish.assert_called_once_with("/path/to/phen")
    
    def test_phen_copy():
        with patch("phen.copy") as mock_copy:
            args = argparse.Namespace(phen_dir="/path/to/phen", target_dir="/path/to/target", version="1.0")
            phen_copy(args)
            mock_copy.assert_called_once_with("/path/to/phen", "/path/to/target", "1.0")
    
    def test_phen_diff():
        with patch("phen.diff") as mock_diff:
            args = argparse.Namespace(phen_dir="/path/to/phen", phen_dir_old="/path/to/old_phen")
            phen_diff(args)
            mock_diff.assert_called_once_with("/path/to/phen", "/path/to/old_phen")
    
    def test_phen_local():
        with patch("phen.diff") as mock_diff:
            args = argparse.Namespace(phen_dir="/path/to/phen", phen_dir_old="/path/to/old_phen")
            phen_diff(args)
            mock_diff.assert_called_once_with("/path/to/phen", "/path/to/old_phen")