-
Notifications
You must be signed in to change notification settings - Fork 44.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor challenges to use cycle count instead of time (#4222)
Co-authored-by: Richard Beales <[email protected]>
- Loading branch information
1 parent
17c45ee
commit 6c4426d
Showing
23 changed files
with
1,088 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[mypy] | ||
follow_imports = skip | ||
check_untyped_defs = True | ||
disallow_untyped_defs = True | ||
files = tests/integration/challenges/**/*.py | ||
|
||
[mypy-requests.*] | ||
ignore_missing_imports = True | ||
[mypy-yaml.*] | ||
ignore_missing_imports = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
tests/integration/challenges/basic_abilities/test_browse_website.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
from pytest_mock import MockerFixture | ||
|
||
from autogpt.agent import Agent | ||
from autogpt.commands.file_operations import read_file | ||
from tests.integration.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 | ||
def test_browse_website( | ||
browser_agent: Agent, | ||
patched_api_requestor: MockerFixture, | ||
monkeypatch: pytest.MonkeyPatch, | ||
) -> None: | ||
file_path = browser_agent.workspace.get_path("browse_website.txt") | ||
run_interaction_loop(monkeypatch, browser_agent, CYCLE_COUNT) | ||
|
||
content = read_file(file_path) | ||
assert "£25.89" in content, f"Expected £25.89, got {content}" |
23 changes: 23 additions & 0 deletions
23
tests/integration/challenges/basic_abilities/test_write_file.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
from pytest_mock import MockerFixture | ||
|
||
from autogpt.agent import Agent | ||
from autogpt.commands.file_operations import read_file | ||
from tests.integration.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 | ||
def test_write_file( | ||
writer_agent: Agent, | ||
patched_api_requestor: MockerFixture, | ||
monkeypatch: pytest.MonkeyPatch, | ||
) -> 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) | ||
assert content == "Hello World", f"Expected 'Hello World', got {content}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import pytest | ||
from _pytest.config import Config | ||
from _pytest.config.argparsing import Parser | ||
from _pytest.fixtures import FixtureRequest | ||
from _pytest.monkeypatch import MonkeyPatch | ||
|
||
|
||
def pytest_addoption(parser): | ||
def pytest_addoption(parser: Parser) -> None: | ||
parser.addoption( | ||
"--level", action="store", default=None, type=int, help="Specify test level" | ||
) | ||
|
||
|
||
def pytest_configure(config): | ||
def pytest_configure(config: Config) -> None: | ||
config.option.level = config.getoption("--level") | ||
|
||
|
||
@pytest.fixture | ||
def user_selected_level(request) -> int: | ||
def user_selected_level(request: FixtureRequest) -> int: | ||
## used for challenges in the goal oriented tests | ||
return request.config.option.level |
31 changes: 8 additions & 23 deletions
31
tests/integration/challenges/information_retrieval/test_information_retrieval_challenge_a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 7 additions & 21 deletions
28
tests/integration/challenges/kubernetes/test_kubernetes_template_challenge_a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6c4426d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deployment failed with the following error: