def darwin_client(darwin_config_path: Path, darwin_datasets_path: Path, team_slug: str) -> Client: config = Config(darwin_config_path) config.put(["global", "api_endpoint"], "http://localhost/api") config.put(["global", "base_url"], "http://localhost") config.put(["teams", team_slug, "api_key"], "mock_api_key") config.put(["teams", team_slug, "datasets_dir"], str(darwin_datasets_path)) return Client(config=config)
def local_config_file(team_slug: str, darwin_datasets_path: Path): darwin_path = Path.home() / ".darwin" backup_darwin_path = Path.home() / ".darwin_backup" config_path = darwin_path / "config.yaml" # Executed before the test if darwin_path.exists(): shutil.move(str(darwin_path), str(backup_darwin_path)) darwin_path.mkdir() config = Config(config_path) config.put(["global", "api_endpoint"], "http://localhost/api") config.put(["global", "base_url"], "http://localhost") config.put(["teams", team_slug, "api_key"], "mock_api_key") config.put(["teams", team_slug, "datasets_dir"], str(darwin_datasets_path)) # Useful if the test needs to reuse attrs yield config # Executed after the test shutil.rmtree(darwin_path) if backup_darwin_path.exists(): shutil.move(backup_darwin_path, darwin_path)