mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-31 21:04:25 +01:00
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
This commit is contained in:
committed by
GitHub
parent
8a881f70a3
commit
dafbd11686
0
tests/challenges/basic_abilities/__init__.py
Normal file
0
tests/challenges/basic_abilities/__init__.py
Normal file
10
tests/challenges/basic_abilities/goal_oriented_tasks.md
Normal file
10
tests/challenges/basic_abilities/goal_oriented_tasks.md
Normal file
@@ -0,0 +1,10 @@
|
||||
If the goal oriented task pipeline fails, it means:
|
||||
- you somehow changed the way the system prompt is generated
|
||||
- or you broke autogpt.
|
||||
|
||||
To know which one, you can run the following command:
|
||||
```bash
|
||||
pytest -s -k tests/integration/goal_oriented
|
||||
|
||||
If the test is successful, it will record new cassettes in VCR. Then you can just push these to your branch and the pipeline
|
||||
will pass
|
||||
25
tests/challenges/basic_abilities/test_browse_website.py
Normal file
25
tests/challenges/basic_abilities/test_browse_website.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
|
||||
from autogpt.agent import Agent
|
||||
from tests.challenges.challenge_decorator.challenge_decorator import challenge
|
||||
from tests.challenges.utils import run_interaction_loop
|
||||
from tests.utils import requires_api_key
|
||||
|
||||
CYCLE_COUNT = 2
|
||||
|
||||
|
||||
@requires_api_key("OPENAI_API_KEY")
|
||||
@pytest.mark.vcr
|
||||
@challenge
|
||||
def test_browse_website(
|
||||
browser_agent: Agent,
|
||||
patched_api_requestor: None,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
level_to_run: int,
|
||||
) -> None:
|
||||
file_path = browser_agent.workspace.get_path("browse_website.txt")
|
||||
run_interaction_loop(monkeypatch, browser_agent, CYCLE_COUNT)
|
||||
|
||||
# content = read_file(file_path, config)
|
||||
content = open(file_path, encoding="utf-8").read()
|
||||
assert "£25.89" in content, f"Expected £25.89, got {content}"
|
||||
28
tests/challenges/basic_abilities/test_write_file.py
Normal file
28
tests/challenges/basic_abilities/test_write_file.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from autogpt.agent import Agent
|
||||
from autogpt.commands.file_operations import read_file
|
||||
from autogpt.config import Config
|
||||
from tests.challenges.challenge_decorator.challenge_decorator import challenge
|
||||
from tests.challenges.utils import run_interaction_loop
|
||||
from tests.utils import requires_api_key
|
||||
|
||||
CYCLE_COUNT = 3
|
||||
|
||||
|
||||
@requires_api_key("OPENAI_API_KEY")
|
||||
@pytest.mark.vcr
|
||||
@challenge
|
||||
def test_write_file(
|
||||
writer_agent: Agent,
|
||||
patched_api_requestor: MockerFixture,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
config: Config,
|
||||
level_to_run: int,
|
||||
) -> None:
|
||||
file_path = str(writer_agent.workspace.get_path("hello_world.txt"))
|
||||
run_interaction_loop(monkeypatch, writer_agent, CYCLE_COUNT)
|
||||
|
||||
content = read_file(file_path, config)
|
||||
assert content == "Hello World", f"Expected 'Hello World', got {content}"
|
||||
Reference in New Issue
Block a user