Exemple #1
0
def test_config_values(monkeypatch):
    fake_config = br.TempFile()
    fake_config.write(
        "[DEFAULT]\nuser_hash = ABCDEFG\ndiagnostics = True\nemail = [email protected]"
        "\nshortcuts = /usr/local/sb,/usr/local/alb")
    fake_config.close()
    config_path = fake_config.path

    monkeypatch.setattr(br, "resource_filename", lambda *_: config_path)
    options = br.config_values()
    assert options["user_hash"] == "ABCDEFG"
    assert options["diagnostics"]
    assert options["email"] == "*****@*****.**"
    assert options["shortcuts"] == ['/usr/local/sb', '/usr/local/alb']

    def mock_keyerror(*args, **kwargs):
        raise KeyError(args, kwargs)

    monkeypatch.setattr(ConfigParser, "getboolean", mock_keyerror)
    monkeypatch.setattr(ConfigParser, "get", mock_keyerror)
    options = br.config_values()
    assert options["user_hash"] == "hashless"
    assert not options["diagnostics"]
    assert options["email"] == "*****@*****.**"

    def mock_distributionerror(*args, **kwargs):
        raise DistributionNotFound(args, kwargs)

    monkeypatch.setattr(br, "resource_filename", mock_distributionerror)
    options = br.config_values()
    assert not options["data_dir"]
Exemple #2
0
def uninstall():
    if br.ask("Are you sure you want to completely remove BuddySuite from your system y/[n]? ", default="no"):
        # Need to run os.path.split() twice to get to the actual install dir
        install_dir, toss = os.path.split(buddysuite.__file__)
        install_dir, toss = os.path.split(install_dir)
        # Delete all custom shortcuts
        config = br.config_values()
        for shortcut in config["shortcuts"]:
            try:
                os.remove(shortcut)
            except FileNotFoundError:
                pass

        # Delete all gateway programs
        for buddy in ['seqbuddy', 'alignbuddy', 'phylobuddy', 'databasebuddy', 'buddysuite']:
            try:
                os.remove(shutil.which(buddy))
            except FileNotFoundError:
                pass

        # Delete the main site-packages module
        try:
            shutil.rmtree(install_dir)
        except FileNotFoundError:
            pass
    return
Exemple #3
0
def test_ncbiclient_init():
    dbbuddy = Db.DbBuddy(", ".join(ACCNS[:3]))
    client = Db.NCBIClient(dbbuddy)
    assert client.Entrez.email == br.config_values()['email']
    assert client.Entrez.tool == "buddysuite"
    assert hash(dbbuddy) == hash(client.dbbuddy)
    assert type(client.http_errors_file) == br.TempFile
    assert type(client.results_file) == br.TempFile
    assert client.max_url == 1000
    assert client.max_attempts == 5