Files
Auto-GPT/tests/unit/test_make_agent.py
Reinier van der Leer dafbd11686 Rearrange tests & fix CI (#4596)
* Rearrange tests into unit/integration/challenge categories

* Fix linting + `tests.challenges` imports

* Fix obscured duplicate test in test_url_validation.py

* Move VCR conftest to tests.vcr

* Specify tests to run & their order (unit -> integration -> challenges) in CI

* Fail Docker CI when tests fail

* Fix import & linting errors in tests

* Fix `get_text_summary`

* Fix linting errors

* Clean up pytest args in CI

* Remove bogus tests from GoCodeo
2023-06-06 10:48:49 -07:00

25 lines
901 B
Python

from unittest.mock import MagicMock
from pytest_mock import MockerFixture
from autogpt.app import list_agents, start_agent
from autogpt.config import Config
def test_make_agent(config: Config, mocker: MockerFixture) -> None:
"""Test that an agent can be created"""
mock = mocker.patch("openai.ChatCompletion.create")
response = MagicMock()
# del response.error
response.choices[0].messages[0].content = "Test message"
response.usage.prompt_tokens = 1
response.usage.completion_tokens = 1
mock.return_value = response
start_agent("Test Agent", "chat", "Hello, how are you?", config, "gpt-3.5-turbo")
agents = list_agents(config)
assert "List of agents:\n0: chat" == agents
start_agent("Test Agent 2", "write", "Hello, how are you?", config, "gpt-3.5-turbo")
agents = list_agents(config)
assert "List of agents:\n0: chat\n1: write" == agents