Files
Auto-GPT/tests/integration/challenges/kubernetes/test_kubernetes_template_challenge_a.py
2023-05-15 21:44:36 -05:00

37 lines
1.2 KiB
Python

import pytest
import yaml
from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file
from tests.integration.challenges.utils import run_interaction_loop, run_multiple_times
from tests.utils import requires_api_key
CYCLE_COUNT = 6
@pytest.mark.skip("This challenge hasn't been beaten yet.")
@pytest.mark.vcr
@requires_api_key("OPENAI_API_KEY")
@run_multiple_times(3)
def test_kubernetes_template_challenge_a(
kubernetes_agent: Agent, monkeypatch: pytest.MonkeyPatch
) -> None:
"""
Test the challenge_a function in a given agent by mocking user inputs
and checking the output file content.
:param get_company_revenue_agent: The agent to test.
:param monkeypatch: pytest's monkeypatch utility for modifying builtins.
"""
run_interaction_loop(monkeypatch, kubernetes_agent, CYCLE_COUNT)
file_path = str(kubernetes_agent.workspace.get_path("kube.yaml"))
content = read_file(file_path)
for word in ["apiVersion", "kind", "metadata", "spec"]:
assert word in content, f"Expected the file to contain {word}"
content = yaml.safe_load(content)
for word in ["Service", "Deployment", "Pod"]:
assert word in content["kind"], f"Expected the file to contain {word}"