Skip to content

Commit

Permalink
test: close test client after testing and make manifest_str be pytest…
Browse files Browse the repository at this point in the history
….fixture
  • Loading branch information
grieve54706 committed Oct 16, 2024
1 parent c1d330b commit b56090c
Show file tree
Hide file tree
Showing 11 changed files with 2,595 additions and 2,649 deletions.
31 changes: 17 additions & 14 deletions ibis-server/tests/routers/test_ibis.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import base64

import orjson
import pytest
from fastapi.testclient import TestClient

from app.main import app

client = TestClient(app)

manifest = {
"catalog": "my_catalog",
"schema": "my_schema",
Expand All @@ -17,21 +16,25 @@
"columns": [
{"name": "orderkey", "expression": "o_orderkey", "type": "integer"}
],
"primaryKey": "orderkey",
},
],
}

manifest_str = base64.b64encode(orjson.dumps(manifest)).decode("utf-8")

@pytest.fixture
def manifest_str():
return base64.b64encode(orjson.dumps(manifest)).decode("utf-8")

def test_dry_plan():
response = client.post(
url="/v2/connector/dry-plan",
json={
"manifestStr": manifest_str,
"sql": 'SELECT orderkey FROM "Orders" LIMIT 1',
},
)
assert response.status_code == 200
assert response.text is not None

with TestClient(app) as client:

def test_dry_plan(manifest_str):
response = client.post(
url="/v2/connector/dry-plan",
json={
"manifestStr": manifest_str,
"sql": 'SELECT orderkey FROM "Orders" LIMIT 1',
},
)
assert response.status_code == 200
assert response.text is not None
Loading

0 comments on commit b56090c

Please sign in to comment.