Beispiel #1
0
def test_prefix_string():
    """
    assert True when non-empty string is given
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.prefix = "some_isolate"
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._check_prefix()
Beispiel #2
0
def test_prefix_empty():
    """
    assert True when non-empty string is given
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.prefix = ""
        amr_obj.logger = logging.getLogger(__name__)
        with pytest.raises(SystemExit):
            amr_obj._check_prefix()
Beispiel #3
0
def test_check_run_type_single():
    """
    assert true when a contigs file is provided and batch recorded as assembly
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'contigs.fa'}"
        amr_obj.prefix = 'somename'
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._get_input_shape() == 'assembly'
Beispiel #4
0
def test_check_run_type_batch():
    """
    assert true when a tab file is provided with two columns
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch.txt'}"
        amr_obj.prefix = ''
        amr_obj.logger = logging.getLogger(__name__)
        assert amr_obj._get_input_shape() == 'batch'
Beispiel #5
0
def test_check_run_type_wrong_data():
    """
    assert true when error raised because input is wrong shape
    """
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch_fail.txt'}"
        amr_obj.prefix = ''
        amr_obj.logger = logging.getLogger(__name__)
        with pytest.raises(SystemExit):
            amr_obj._get_input_shape()
Beispiel #6
0
def test_setup_fail():
    with patch.object(SetupAMR, "__init__", lambda x: None):
        amr_obj = SetupAMR()
        amr_obj.contigs = f"{test_folder / 'batch.txt'}"
        amr_obj.prefix = ''
        amr_obj.jobs = 16
        amr_obj.species = ''
        amr_obj.logger = logging.getLogger(__name__)
        T = collections.namedtuple(
            'T', ['run_type', 'input', 'prefix', 'jobs', 'organism'])
        input_data = T('batch', amr_obj.contigs, amr_obj.prefix, amr_obj.jobs,
                       amr_obj.species)
        assert amr_obj.setup() == input_data