-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
29 lines (21 loc) · 850 Bytes
/
conftest.py
File metadata and controls
29 lines (21 loc) · 850 Bytes
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
import os
import psycopg2
import pytest
# from dotenv import find_dotenv, load_dotenv
@pytest.fixture(scope="module")
def setup_env_variables() -> None:
os.environ.clear()
os.environ["TIMESCALE_SERVICE_URL"] = "postgres://postgres:postgres@localhost:5432/postgres"
os.environ["OPENAI_API_KEY"] = "fake key"
@pytest.fixture(scope="module")
def service_url(setup_env_variables: None) -> str: # noqa: ARG001
# _ = load_dotenv(find_dotenv(), override=True)
return os.environ["TIMESCALE_SERVICE_URL"]
@pytest.fixture(scope="module", autouse=True)
def setup_db(service_url: str) -> None:
conn = psycopg2.connect(service_url)
with conn.cursor() as cursor:
cursor.execute("CREATE EXTENSION IF NOT EXISTS ai CASCADE;")
cursor.execute("CREATE SCHEMA IF NOT EXISTS temp;")
conn.commit()
conn.close()