-
-
Notifications
You must be signed in to change notification settings - Fork 323
/
Copy pathconftest.py
44 lines (31 loc) · 978 Bytes
/
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
44
import pytest
def pytest_configure(config):
import sys
sys._called_from_test = True
@pytest.fixture
def log_path(tmpdir):
return tmpdir / "logs.db"
@pytest.fixture
def keys_path(tmpdir):
return tmpdir / "keys.json"
@pytest.fixture
def templates_path(tmpdir):
path = tmpdir / "templates"
path.mkdir()
return path
@pytest.fixture(autouse=True)
def env_setup(monkeypatch, log_path, keys_path, templates_path):
monkeypatch.setenv("LLM_KEYS_PATH", str(keys_path))
monkeypatch.setenv("LLM_LOG_PATH", str(log_path))
monkeypatch.setenv("LLM_TEMPLATES_PATH", str(templates_path))
@pytest.fixture
def mocked_openai(requests_mock):
return requests_mock.post(
"https://api.openai.com/v1/chat/completions",
json={
"model": "gpt-3.5-turbo",
"usage": {},
"choices": [{"message": {"content": "Bob, Alice, Eve"}}],
},
headers={"Content-Type": "application/json"},
)