2023-04-23 19:36:04 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
2023-04-22 19:39:56 +00:00
|
|
|
|
2023-04-25 18:12:24 +00:00
|
|
|
from autogpt.api_manager import ApiManager
|
|
|
|
from autogpt.api_manager import api_manager as api_manager_
|
2023-04-23 23:40:53 +00:00
|
|
|
from autogpt.config import Config
|
2023-04-23 19:36:04 +00:00
|
|
|
from autogpt.workspace import Workspace
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def workspace_root(tmp_path) -> Path:
|
|
|
|
return tmp_path / "home/users/monty/auto_gpt_workspace"
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def workspace(workspace_root: Path) -> Workspace:
|
|
|
|
workspace_root = Workspace.make_workspace(workspace_root)
|
|
|
|
return Workspace(workspace_root, restrict_to_workspace=True)
|
2023-04-23 23:40:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def config(workspace: Workspace) -> Config:
|
|
|
|
config = Config()
|
|
|
|
|
|
|
|
# Do a little setup and teardown since the config object is a singleton
|
|
|
|
old_ws_path = config.workspace_path
|
|
|
|
config.workspace_path = workspace.root
|
|
|
|
yield config
|
|
|
|
config.workspace_path = old_ws_path
|
2023-04-25 18:12:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def api_manager() -> ApiManager:
|
|
|
|
old_attrs = api_manager_.__dict__.copy()
|
|
|
|
api_manager_.reset()
|
|
|
|
yield api_manager_
|
|
|
|
api_manager_.__dict__.update(old_attrs)
|