Skip to content

Commit

Permalink
chore: refactor tests add vcr mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Askir committed Dec 12, 2024
1 parent da7b72b commit 6bb0414
Show file tree
Hide file tree
Showing 14 changed files with 2,205 additions and 192 deletions.
298 changes: 298 additions & 0 deletions projects/pgai/tests/vectorizer/cassettes/test_joined_loading.yaml

Large diffs are not rendered by default.

825 changes: 825 additions & 0 deletions projects/pgai/tests/vectorizer/cassettes/test_sqlalchemy.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
interactions:
- request:
body: '{"input": [[22333, 6975, 374, 264, 27084, 315, 21075, 11478, 430, 20682,
6067, 311, 4048, 323, 7417, 505, 3217, 13]], "model": "text-embedding-3-large",
"dimensions": 1536, "encoding_format": "float"}'
headers:
accept:
- application/json
accept-encoding:
- gzip, deflate
connection:
- keep-alive
content-length:
- '200'
content-type:
- application/json
host:
- api.openai.com
user-agent:
- AsyncOpenAI/Python 1.53.0
x-stainless-arch:
- arm64
x-stainless-async:
- async:asyncio
x-stainless-lang:
- python
x-stainless-os:
- MacOS
x-stainless-package-version:
- 1.53.0
x-stainless-retry-count:
- '0'
x-stainless-runtime:
- CPython
x-stainless-runtime-version:
- 3.10.15
method: POST
uri: https://api.openai.com/v1/embeddings
response:
body:
string: !!binary |
H4sIAAAAAAAAA4xZTY5etxHc+xSDWTtGV/W/rpKVHQmBgsRZRIsAvnzAkRLrFQeBtdCC8z6ySVZX
VTd/++Hl5fWfv/zt01++vH54ef375399ef3xjH38+cvPrx9e/vzDy8vLy29v/z++/PSPXz59/Pj5
17++ff72x8+/fvz079cPL/a/kd8/+u9M55/9ZOakl3f9+P0oLden/PfBP9lPhjUmMTLKzPJ8TmA2
zaiZfn5sQ3OzktGy6MXkYw7Qi9b5/JY2gxoJwnKbXvGcwTowNS5BcGKMujurDBtcExtmQ4JAshb2
XI1AJqjTxg63SmZw620mnzvOMoOFhMv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Ug1JK1n+Cajz7zAchBkWMISpJcJaCxi08XScRA+cfGa5jp
1pJQJjA2crLX876Pw/HYb/p8vp81juRW/qIQaS1Oz/YcwdUGurG9hBRvwIusFvDBMT+pnBFWrbQW
T7EyVu37KVNQ6QrDwSXnnNcP/3L9+68ffvzxL/jcl9//+OXbb19++vHL92//8/3rt9//+u2XX/7z
b79+ja+//fyPX799uT703//8+ddvX3768X+v//zl7//44/e/f/+P73/817e//fPLTz/+WcK+fP/j
+8+//d+f/4A/9a8f/g0AAP//AwBHX2NkE4IAAA==
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8f0d577a0d31e50a-TXL
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Thu, 12 Dec 2024 11:23:20 GMT
Server:
- cloudflare
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
access-control-allow-origin:
- '*'
access-control-expose-headers:
- X-Request-ID
alt-svc:
- h3=":443"; ma=86400
openai-model:
- text-embedding-3-large
openai-organization:
- timescale-team
openai-processing-ms:
- '70'
openai-version:
- '2020-10-01'
strict-transport-security:
- max-age=31536000; includeSubDomains; preload
x-ratelimit-limit-requests:
- '10000'
x-ratelimit-limit-tokens:
- '5000000'
x-ratelimit-remaining-requests:
- '9999'
x-ratelimit-remaining-tokens:
- '4999981'
x-ratelimit-reset-requests:
- 6ms
x-ratelimit-reset-tokens:
- 0s
x-request-id:
- req_ea6c79e762c2ef542d4a6f551052f7c5
status:
code: 200
message: OK
version: 1
6 changes: 3 additions & 3 deletions projects/pgai/tests/vectorizer/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
@pytest.fixture(autouse=True)
def __env_setup(): # type:ignore
# Capture the current environment variables to restore after the test. The
# lambda function sets an evironment variable for using the secrets. We
# lambda function sets an environment variable for using the secrets. We
# need to clear the environment after a test runs.

load_dotenv()
original_env = os.environ.copy()

# Use the existing tiktoken cache
Expand Down Expand Up @@ -66,11 +65,12 @@ def postgres_container():
image = DockerImage(path=extension_dir, tag="pgai-test-db").build( # type: ignore
target="pgai-test-db"
)
openai_api_key = os.environ["OPENAI_API_KEY"]
with PostgresContainer(
image=str(image),
username="tsdbquerier",
password="my-password",
dbname="tsdb",
driver=None,
).with_env("OPENAI_API_KEY", os.environ["OPENAI_API_KEY"]) as postgres:
).with_env("OPENAI_API_KEY", openai_api_key) as postgres:
yield postgres
6 changes: 6 additions & 0 deletions projects/pgai/tests/vectorizer/extensions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ def initialized_engine(
with engine.connect() as conn:
conn.execute(text("DROP SCHEMA public CASCADE; CREATE SCHEMA public;"))
conn.commit()

@pytest.fixture(autouse=True)
def set_dummy_openai_key(monkeypatch: pytest.MonkeyPatch) -> Generator[None, None, None]:
"""Set a dummy OpenAI API key for testing."""
monkeypatch.setenv("OPENAI_API_KEY", "dummy_key")
yield
24 changes: 8 additions & 16 deletions projects/pgai/tests/vectorizer/extensions/test_sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from click.testing import CliRunner
from typing import Any

from sqlalchemy import Column, Engine, Integer, Text
from sqlalchemy.orm import Session, declarative_base
from sqlalchemy.sql import text
from testcontainers.postgres import PostgresContainer # type: ignore

from pgai.cli import vectorizer_worker
from pgai.sqlalchemy import embedding_relationship
from tests.vectorizer.extensions.utils import run_vectorizer_worker


def test_sqlalchemy(postgres_container: PostgresContainer, initialized_engine: Engine):
def test_sqlalchemy(
postgres_container: PostgresContainer, initialized_engine: Engine, vcr_: Any
):
db_url = postgres_container.get_connection_url()
# Create engine and base
Base = declarative_base()
Expand Down Expand Up @@ -64,19 +67,8 @@ class BlogPost(Base):
session.add_all(posts)
session.commit()

CliRunner().invoke(
vectorizer_worker,
[
"--db-url",
db_url,
"--once",
"--vectorizer-id",
"1",
"--concurrency",
"1",
],
catch_exceptions=False,
)
with vcr_.use_cassette("test_sqlalchemy.yaml"):
run_vectorizer_worker(db_url, 1)

with Session(initialized_engine) as session:
# Test 1: Access embedding class directly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import Any

import numpy as np
from click.testing import CliRunner
from sqlalchemy import Column, Engine, Text
from sqlalchemy.orm import DeclarativeBase, Session
from sqlalchemy.sql import text
from testcontainers.postgres import PostgresContainer # type: ignore

from pgai.cli import vectorizer_worker
from pgai.sqlalchemy import embedding_relationship
from tests.vectorizer.extensions.utils import run_vectorizer_worker


class Base(DeclarativeBase):
Expand All @@ -23,24 +24,10 @@ class Author(Base):
)


def run_vectorizer_worker(db_url: str, vectorizer_id: int) -> None:
CliRunner().invoke(
vectorizer_worker,
[
"--db-url",
db_url,
"--once",
"--vectorizer-id",
str(vectorizer_id),
"--concurrency",
"1",
],
catch_exceptions=False,
)


def test_vectorizer_composite_key(
postgres_container: PostgresContainer, initialized_engine: Engine
postgres_container: PostgresContainer,
initialized_engine: Engine,
vcr_: Any,
):
"""Test vectorizer with a composite primary key."""
db_url = postgres_container.get_connection_url()
Expand Down Expand Up @@ -74,11 +61,11 @@ def test_vectorizer_composite_key(
session.commit()

# Run vectorizer worker
run_vectorizer_worker(db_url, 1)
with vcr_.use_cassette("test_vectorizer_composite_key.yaml"):
run_vectorizer_worker(db_url, 1)

# Verify embeddings were created
with Session(initialized_engine) as session:
# Verify embedding class was created correctly
assert Author.bio_embeddings.__name__ == "BioEmbeddingsEmbedding"

# Check embeddings exist and have correct properties
Expand Down
Loading

0 comments on commit 6bb0414

Please sign in to comment.