You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
motief/tests/test_migration_embeddings.py

31 lines
1001 B

import os
import pytest
def test_embeddings_migration_creates_table(tmp_path):
try:
import duckdb
except ImportError:
pytest.skip("duckdb is not installed")
db_file = str(tmp_path / "migrations_test.db")
conn = duckdb.connect(database=db_file)
try:
sql = open("migrations/2026-03-19-add-embeddings.sql", "r").read()
conn.execute(sql)
# Use sequence to set id if present, otherwise provide explicit id
try:
next_id = conn.execute("SELECT nextval('embeddings_id_seq')").fetchone()[0]
except Exception:
next_id = 1
conn.execute(
"INSERT INTO embeddings (id, motion_id, model, vector) VALUES (?, ?, ?, ?)",
(next_id, 1, "m1", "[0.1, 0.2]"),
)
res = conn.execute(
"SELECT motion_id, model FROM embeddings WHERE motion_id = 1"
).fetchall()
assert len(res) == 1
assert res[0][1] == "m1"
finally:
conn.close()