2023-05-13 23:07:37 +00:00
|
|
|
import os
|
2023-04-23 19:36:04 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
2023-04-28 12:51:29 +00:00
|
|
|
from pytest_mock import MockerFixture
|
2023-04-22 19:39:56 +00:00
|
|
|
|
2023-05-25 18:31:11 +00:00
|
|
|
from autogpt.config.config import Config
|
|
|
|
from autogpt.llm.api_manager import ApiManager
|
2023-04-23 19:36:04 +00:00
|
|
|
from autogpt.workspace import Workspace
|
2023-04-27 17:16:56 +00:00
|
|
|
|
2023-05-25 18:31:11 +00:00
|
|
|
pytest_plugins = ["tests.integration.agent_factory", "tests.integration.memory.utils"]
|
2023-04-23 19:36:04 +00:00
|
|
|
|
2023-05-13 23:07:37 +00:00
|
|
|
PROXY = os.environ.get("PROXY")
|
|
|
|
|
2023-04-23 19:36:04 +00:00
|
|
|
|
|
|
|
@pytest.fixture()
|
2023-04-28 12:51:29 +00:00
|
|
|
def workspace_root(tmp_path: Path) -> Path:
|
2023-04-23 19:36:04 +00:00
|
|
|
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()
|
2023-04-28 12:51:29 +00:00
|
|
|
def config(mocker: MockerFixture, workspace: Workspace) -> Config:
|
2023-04-23 23:40:53 +00:00
|
|
|
config = Config()
|
|
|
|
|
|
|
|
# Do a little setup and teardown since the config object is a singleton
|
2023-04-28 12:51:29 +00:00
|
|
|
mocker.patch.multiple(
|
|
|
|
config,
|
|
|
|
workspace_path=workspace.root,
|
|
|
|
file_logger_path=workspace.get_path("file_logger.txt"),
|
|
|
|
)
|
2023-04-23 23:40:53 +00:00
|
|
|
yield config
|
2023-04-27 17:16:56 +00:00
|
|
|
|
2023-04-25 18:12:24 +00:00
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def api_manager() -> ApiManager:
|
2023-04-26 16:37:49 +00:00
|
|
|
if ApiManager in ApiManager._instances:
|
|
|
|
del ApiManager._instances[ApiManager]
|
|
|
|
return ApiManager()
|