Skip to content

Commit 90f4541

Browse files
authored
Create httpserver_test.py
1 parent 68876e8 commit 90f4541

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/python/httpserver_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import duckdb
2+
import os
3+
import pytest
4+
5+
# Get a fresh connection to DuckDB with the community extension binary loaded
6+
@pytest.fixture
7+
def duckdb_conn():
8+
extension_binary = os.getenv('HTTPSERVER_EXTENSION_BINARY_PATH')
9+
if (extension_binary == ''):
10+
raise Exception('Please make sure the `HTTPSERVER_EXTENSION_BINARY_PATH` is set to run the python tests')
11+
conn = duckdb.connect('', config={'allow_unsigned_extensions': 'true'})
12+
conn.execute(f"load '{extension_binary}'")
13+
return conn
14+
15+
def test_quack(duckdb_conn):
16+
duckdb_conn.execute("SELECT httpserve_start('0.0.0.0', 8123, '');");
17+
res = duckdb_conn.fetchall()
18+
assert(res[0][0] == "HTTP server started on 0.0.0.0:8123");
19+
20+
def test_quack(duckdb_conn):
21+
duckdb_conn.execute("SELECT * FROM read_json_auto('http://localhost:8123/?q=SELECT 1');");
22+
res = duckdb_conn.fetchall()
23+
assert(res[0][0] == "1");

0 commit comments

Comments
 (0)