1
0
Fork 0

Adding upstream version 1.1.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 20:22:59 +01:00
parent 9c1e264be3
commit f19547bec9
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
22 changed files with 4449 additions and 0 deletions

40
tests/conftest.py Normal file
View file

@ -0,0 +1,40 @@
from __future__ import annotations
import sys
from typing import Generator
import psycopg
import pytest
from harlequin_postgres.adapter import (
HarlequinPostgresAdapter,
HarlequinPostgresConnection,
)
if sys.version_info < (3, 10):
pass
else:
pass
TEST_DB_CONN = "postgresql://postgres:for-testing@localhost:5432"
@pytest.fixture
def connection() -> Generator[HarlequinPostgresConnection, None, None]:
pgconn = psycopg.connect(conninfo=TEST_DB_CONN, dbname="postgres")
pgconn.autocommit = True
cur = pgconn.cursor()
cur.execute("drop database if exists test;")
cur.execute("create database test;")
cur.close()
pgconn.close()
conn = HarlequinPostgresAdapter(
conn_str=(f"{TEST_DB_CONN}",), dbname="test"
).connect()
yield conn
conn.close()
pgconn = psycopg.connect(conninfo=TEST_DB_CONN, dbname="postgres")
pgconn.autocommit = True
cur = pgconn.cursor()
cur.execute("drop database if exists test;")
cur.close()
pgconn.close()