-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconftest.py
43 lines (33 loc) · 1.18 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from aicodebot.helpers import create_and_write_file
from click.testing import CliRunner
from contextlib import contextmanager
from git import Repo
from pathlib import Path
import os, pytest
@pytest.fixture
def cli_runner():
# Create a Click CLI runner that can be used to invoke the CLI
return CliRunner()
@pytest.fixture
def temp_git_repo(tmp_path):
# Create a temporary git repository that can be used for testing
repo = Repo.init(tmp_path)
with repo.config_writer() as git_config:
git_config.set_value("user", "name", "AICodeBot Test")
git_config.set_value("user", "email", "test@aicodebot.dev")
create_and_write_file(tmp_path / "initial_commit.txt", "This is a test file.")
repo.index.add(["initial_commit.txt"])
repo.index.commit("Initial commit")
return repo
@contextmanager
def in_temp_directory(tmp_path):
old_dir = Path.cwd()
os.chdir(tmp_path)
try:
yield
finally:
os.chdir(old_dir)
@pytest.fixture(autouse=True)
def vcr_config():
# Strip out the authorization header from the VCR cassettes, so we don't check in our API key
return {"filter_headers": ["authorization", "openai-organization"]}