Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

New Challenge test_information_retrieval_challenge_c (#4855)

NeonN3mesis2fcd91b765e8
diff --git a/tests/challenges/current_score.json b/tests/challenges/current_score.json
index 732e739176..524f4fd946 100644
--- a/tests/challenges/current_score.json
+++ b/tests/challenges/current_score.json
@@ -23,6 +23,10 @@
"information_retrieval_challenge_b": {
"max_level": 1,
"max_level_beaten": null
+ },
+ "information_retrieval_challenge_c": {
+ "max_level": 3,
+ "max_level_beaten": null
}
},
"kubernetes": {
diff --git a/tests/challenges/information_retrieval/test_information_retrieval_challenge_c.py b/tests/challenges/information_retrieval/test_information_retrieval_challenge_c.py
new file mode 100644
index 0000000000..e827967d4b
--- /dev/null
+++ b/tests/challenges/information_retrieval/test_information_retrieval_challenge_c.py
@@ -0,0 +1,47 @@
+import pytest
+from pytest_mock import MockerFixture
+
+from autogpt.workspace import Workspace
+from tests.challenges.challenge_decorator.challenge_decorator import challenge
+from tests.challenges.utils import get_workspace_path, run_challenge
+
+CYCLE_COUNT = 3
+COO = [["Luke Lafreniere"], ["Luke Lafreniere"], ["Luke Lafreniere 2017"]]
+
+OUTPUT_LOCATION = "output.txt"
+USER_INPUTS = [
+ "Write to a file called output.txt containing the name and title of the current Chief Operating Officer of Floatplane Media.",
+ "Write to a file called output.txt containing the name and title of the current Chief Operating Officer of https://www.floatplane.com.",
+ "Write to a file called output.txt containing the name and title of the current Chief Operating Officer of https://www.floatplane.com and the year it was formed.",
+]
+
+
+@challenge()
+def test_information_retrieval_challenge_c(
+ monkeypatch: pytest.MonkeyPatch,
+ patched_api_requestor: MockerFixture,
+ level_to_run: int,
+ challenge_name: str,
+ workspace: Workspace,
+ patched_make_workspace: pytest.fixture,
+) -> None:
+ """
+ Test the challenge_c function in a given agent by mocking user inputs and checking the output file content.
+
+ :param get_floatplane_ceo_agent: The agent to test.
+ :param monkeypatch: pytest's monkeypatch utility for modifying builtins.
+ """
+ run_challenge(
+ challenge_name,
+ level_to_run,
+ monkeypatch,
+ USER_INPUTS[level_to_run - 1],
+ CYCLE_COUNT,
+ )
+
+ file_path = get_workspace_path(workspace, OUTPUT_LOCATION)
+ with open(file_path, "r") as file:
+ content = file.read()
+ coo_name = COO[level_to_run - 1]
+ for chief in coo_name:
+ assert chief in content, f"Expected the file to contain {chief}"