mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-12 02:34:31 +01:00
* Add categories to command registry * Fix tests * Clean up prompt generation * Rename Performance Evaluations to Best Practices * Move specification of response format from system prompt to Agent.construct_base_prompt * Clean up PromptGenerator class * Add debug logging to AIConfig autogeneration * Clarify prompting and add support for multiple thought processes to Agent * WIP: PlanningAgent * Disable message history by default on BaseAgent * Add CommandOutput and ThoughtProcessOutput type aliases * Fix interrupts in main.py * Use custom exceptions and clean up exception/error handling * Remove duplicate agent_history.py * Update PlanningAgent from upstream * WIP: Support for dynamic in-prompt context * WIP: response formats for PlanningAgent three-stage cycle * Remove browsing overlay & separate browsing from extraction code * Fix human feedback * Fix tests * Include history in Agent prompt generation * Code improvements in agent.py * Add ask_user command and revise system prompt
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import pytest
|
|
from git.exc import GitCommandError
|
|
from git.repo.base import Repo
|
|
|
|
from autogpt.agents.agent import Agent
|
|
from autogpt.agents.utils.exceptions import CommandExecutionError
|
|
from autogpt.commands.git_operations import clone_repository
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_clone_from(mocker):
|
|
return mocker.patch.object(Repo, "clone_from")
|
|
|
|
|
|
def test_clone_auto_gpt_repository(workspace, mock_clone_from, agent: Agent):
|
|
mock_clone_from.return_value = None
|
|
|
|
repo = "github.com/Significant-Gravitas/Auto-GPT.git"
|
|
scheme = "https://"
|
|
url = scheme + repo
|
|
clone_path = str(workspace.get_path("auto-gpt-repo"))
|
|
|
|
expected_output = f"Cloned {url} to {clone_path}"
|
|
|
|
clone_result = clone_repository(url=url, clone_path=clone_path, agent=agent)
|
|
|
|
assert clone_result == expected_output
|
|
mock_clone_from.assert_called_once_with(
|
|
url=f"{scheme}{agent.config.github_username}:{agent.config.github_api_key}@{repo}",
|
|
to_path=clone_path,
|
|
)
|
|
|
|
|
|
def test_clone_repository_error(workspace, mock_clone_from, agent: Agent):
|
|
url = "https://github.com/this-repository/does-not-exist.git"
|
|
clone_path = str(workspace.get_path("does-not-exist"))
|
|
|
|
mock_clone_from.side_effect = GitCommandError(
|
|
"clone", "fatal: repository not found", ""
|
|
)
|
|
|
|
with pytest.raises(CommandExecutionError):
|
|
clone_repository(url=url, clone_path=clone_path, agent=agent)
|