Skip to content

Commit 2906143

Browse files
authored
test: close test client after testing and make manifest_str be pytest.fixture (#830)
1 parent c1d330b commit 2906143

11 files changed

+2595
-2649
lines changed
+17-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import base64
22

33
import orjson
4+
import pytest
45
from fastapi.testclient import TestClient
56

67
from app.main import app
78

8-
client = TestClient(app)
9-
109
manifest = {
1110
"catalog": "my_catalog",
1211
"schema": "my_schema",
@@ -17,21 +16,25 @@
1716
"columns": [
1817
{"name": "orderkey", "expression": "o_orderkey", "type": "integer"}
1918
],
20-
"primaryKey": "orderkey",
2119
},
2220
],
2321
}
2422

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

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

28-
def test_dry_plan():
29-
response = client.post(
30-
url="/v2/connector/dry-plan",
31-
json={
32-
"manifestStr": manifest_str,
33-
"sql": 'SELECT orderkey FROM "Orders" LIMIT 1',
34-
},
35-
)
36-
assert response.status_code == 200
37-
assert response.text is not None
28+
29+
with TestClient(app) as client:
30+
31+
def test_dry_plan(manifest_str):
32+
response = client.post(
33+
url="/v2/connector/dry-plan",
34+
json={
35+
"manifestStr": manifest_str,
36+
"sql": 'SELECT orderkey FROM "Orders" LIMIT 1',
37+
},
38+
)
39+
assert response.status_code == 200
40+
assert response.text is not None

0 commit comments

Comments
 (0)