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:
Reinier van der Leer
2023-06-06 19:48:49 +02:00
committed by GitHub
parent 8a881f70a3
commit dafbd11686
59 changed files with 150 additions and 377 deletions

View File

@@ -0,0 +1,42 @@
import pytest
from git.exc import GitCommandError
from git.repo.base import Repo
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, config):
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, config=config)
assert clone_result == expected_output
mock_clone_from.assert_called_once_with(
url=f"{scheme}{config.github_username}:{config.github_api_key}@{repo}",
to_path=clone_path,
)
def test_clone_repository_error(workspace, mock_clone_from, config):
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", ""
)
result = clone_repository(url=url, clone_path=clone_path, config=config)
assert "Error: " in result