コード例 #1
0
def test_not_valid_input(monkeypatch):
    print("test not valid input")
    dbpath_tmp = os.path.join(tmpdir, "customdb.fas.nsq")
    with open(dbpath_tmp, "w") as f:
        f.write(">mockDB")
    try:
        mock = batchassist_mock(nodef_input, wrong_input)
        monkeypatch.setattr('builtins.input', mock.prompt_input)
        conf_from_file = Config()
        configpath = get_config_from_file(conf_from_file)[0]
        compare_configfiles(reference_dict, configpath, "3")
        if os.path.isfile(configpath):
            os.remove(configpath)
        configpath = get_config_from_file(conf_from_file)[1]
        compare_configfiles(reference_dict, configpath, "4")
        if os.path.isfile(configpath):
            os.remove(configpath)
        mock = batchassist_mock(nodef_input, wrong_input2)
        monkeypatch.setattr('builtins.input', mock.prompt_input)
        conf_from_file = Config()
        configpath = get_config_from_file(conf_from_file)[0]
        compare_configfiles(reference_dict, configpath, "7")
        if os.path.isfile(configpath):
            os.remove(configpath)
    finally:
        if os.path.isfile(dbpath_tmp):
            os.remove(dbpath_tmp)
コード例 #2
0
def test_nodefault(monkeypatch):
    G.create_directory(tmpdir)
    dbpath_tmp = os.path.join(tmpdir, "customdb.fas.nsq")
    with open(dbpath_tmp, "w") as f:
        f.write(">mockDB")
    try:
        monkeypatch.setattr('builtins.input', nodef_input)
        conf_from_file = Config()
        configpath = get_config_from_file(conf_from_file)[0]
        compare_configfiles(reference_dict, configpath, "3")
        if os.path.isfile(configpath):
            os.remove(configpath)
        configpath = get_config_from_file(conf_from_file)[1]
        compare_configfiles(reference_dict, configpath, "4")
        if os.path.isfile(configpath):
            os.remove(configpath)
        monkeypatch.setattr('builtins.input', nodef_input2)
        conf_from_file = Config()
        configpath = get_config_from_file(conf_from_file)[0]
        compare_configfiles(reference_dict, configpath, "8")
        configpath = get_config_from_file(conf_from_file)[1]
        compare_configfiles(reference_dict, configpath, "9")

    finally:
        if os.path.isfile(dbpath_tmp):
            os.remove(dbpath_tmp)
コード例 #3
0
def test_sys_exit(monkeypatch):
    monkeypatch.setattr('builtins.input', fail_input)
    with pytest.raises(SystemExit):
        conf_from_file = Config()

    monkeypatch.setattr('builtins.input', fail_startinput)
    with pytest.raises(SystemExit):
        conf_from_file = Config()
コード例 #4
0
def test_start_unknown(monkeypatch):
    print("Start unknown")
    mock = batchassist_mock(start_oneinput, start_unknown)
    monkeypatch.setattr('builtins.input', mock.prompt_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "8")
コード例 #5
0
def test_default_input(monkeypatch):
    monkeypatch.setattr('builtins.input', alldef_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "0")
    defdir = os.path.join("/", "Lactobacillus_curvatus")
    if os.path.isdir(defdir):
        shutil.rmtree(defdir)
コード例 #6
0
def test_start_wrong(monkeypatch):
    print("Start wrong")
    mock = batchassist_mock(save_wronginput, start_wronginput)
    monkeypatch.setattr('builtins.input', mock.prompt_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "8")
    if os.path.isfile(configpath):
        os.remove(configpath)
コード例 #7
0
def test_start_all(monkeypatch):
    monkeypatch.setattr('builtins.input', start_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "8")
    if os.path.isfile(configpath):
        os.remove(configpath)
    configpath = get_config_from_file(conf_from_file)[1]
    compare_configfiles(reference_dict, configpath, "9")
    if os.path.isfile(configpath):
        os.remove(configpath)
コード例 #8
0
def test_incomplete_config(monkeypatch):
    testfile = os.path.join(
        "/", "primerdesign", "test", "Lactobacillus_curvatus",
        "config", "config.json")
    incomplete_dict = {
            "target": "lactobacillus_curvatus", "path": "/primerdesign/test"}
    with open(testfile, "w") as f:
        f.write(json.dumps(incomplete_dict))
    monkeypatch.setattr('builtins.input', start_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "5")
コード例 #9
0
def test_offline(monkeypatch):
    monkeypatch.setattr('builtins.input', offline_input)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "1")
    if os.path.isfile(configpath):
        os.remove(configpath)
    configpath = get_config_from_file(conf_from_file)[1]
    compare_configfiles(reference_dict, configpath, "2")
    if os.path.isfile(configpath):
        os.remove(configpath)
    monkeypatch.setattr('builtins.input', offline_input2)
    conf_from_file = Config()
    configpath = get_config_from_file(conf_from_file)[0]
    compare_configfiles(reference_dict, configpath, "1")
    if os.path.isfile(configpath):
        os.remove(configpath)
    configpath = get_config_from_file(conf_from_file)[1]
    compare_configfiles(reference_dict, configpath, "2")
    if os.path.isfile(configpath):
        os.remove(configpath)