-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from jwills/jwills_functional_tests
Add in functional tests for the postgres server
- Loading branch information
Showing
10 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import io | ||
import logging | ||
import os | ||
import re | ||
from typing import Any, Dict, Iterator, List, Optional, Tuple | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import threading | ||
|
||
import pytest | ||
|
||
import duckdb | ||
import psycopg | ||
|
||
from buenavista.examples.duckdb_postgres import create | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def db(): | ||
return duckdb.connect() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def user_password(): | ||
return {"postgres": "postgres1729"} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def duckdb_postgres_server(db, user_password): | ||
try: | ||
server = create(db, ("localhost", 5444), auth=user_password) | ||
server_thread = threading.Thread(target=server.serve_forever) | ||
server_thread.daemon = True | ||
server_thread.start() | ||
yield server | ||
finally: | ||
db.close() | ||
|
||
@pytest.fixture(scope="session") | ||
def conn(duckdb_postgres_server, user_password): | ||
assert duckdb_postgres_server is not None | ||
user, password = list(user_password.items())[0] | ||
conn_str = f"postgresql://{user}:{password}@localhost:5444/memory" | ||
return psycopg.connect(conn_str) | ||
|
||
|
||
def test_select(conn): | ||
cur = conn.cursor() | ||
cur.execute("SELECT 1") | ||
assert cur.fetchone() == (1,) | ||
cur.close() | ||
|
||
def test_pg_version(conn): | ||
cur = conn.cursor() | ||
cur.execute("SELECT pg_catalog.version()") | ||
assert cur.fetchone() == ("PostgreSQL 9.3",) | ||
cur.close() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.