Skip to content

Commit d2c77b9

Browse files
committed
scope integration fixtures for integration tests
1 parent 0e48681 commit d2c77b9

2 files changed

Lines changed: 45 additions & 44 deletions

File tree

src/tests/conftest.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
# load environment variables from a .env file for local testing
2-
from dotenv import load_dotenv
3-
4-
load_dotenv()
5-
6-
from collections.abc import AsyncGenerator # noqa: E402
7-
8-
import pytest # noqa: E402
9-
10-
from bubble_data_api_client import configure, settings # noqa: E402
11-
from bubble_data_api_client.client import raw_client # noqa: E402
12-
from bubble_data_api_client.pool import close_clients # noqa: E402
1+
import pytest
132

143

154
@pytest.fixture
@@ -20,35 +9,3 @@ def test_url() -> str:
209
@pytest.fixture
2110
def test_api_key() -> str:
2211
return "123"
23-
24-
25-
@pytest.fixture(autouse=True)
26-
async def auto_configure_client() -> AsyncGenerator[None]:
27-
"""Automatically configure the client for every test run."""
28-
if not settings.BUBBLE_DATA_API_ROOT_URL:
29-
raise RuntimeError("BUBBLE_DATA_API_ROOT_URL")
30-
if not settings.BUBBLE_API_KEY:
31-
raise RuntimeError("BUBBLE_API_KEY")
32-
33-
configure(
34-
data_api_root_url=settings.BUBBLE_DATA_API_ROOT_URL,
35-
api_key=settings.BUBBLE_API_KEY,
36-
)
37-
38-
yield
39-
40-
await close_clients()
41-
42-
43-
@pytest.fixture
44-
async def bubble_raw_client() -> AsyncGenerator[raw_client.RawClient]:
45-
"""Provide a raw client for testing the low-level API."""
46-
async with raw_client.RawClient() as client_instance:
47-
yield client_instance
48-
49-
50-
@pytest.fixture
51-
def typename() -> str:
52-
"""Return a test typename for integration tests."""
53-
# this typename should exist in the bubble app and should allow CRUD operations
54-
return "IntegrationTest"

src/tests/integration/conftest.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# load environment variables from a .env file for local testing
2+
from dotenv import load_dotenv
3+
4+
load_dotenv()
5+
6+
from collections.abc import AsyncGenerator # noqa: E402
7+
8+
import pytest # noqa: E402
9+
10+
from bubble_data_api_client import configure, settings # noqa: E402
11+
from bubble_data_api_client.client import raw_client # noqa: E402
12+
from bubble_data_api_client.pool import close_clients # noqa: E402
13+
14+
15+
@pytest.fixture(autouse=True)
16+
async def auto_configure_client() -> AsyncGenerator[None]:
17+
"""Automatically configure the client for every integration test."""
18+
if not settings.BUBBLE_DATA_API_ROOT_URL:
19+
raise RuntimeError("BUBBLE_DATA_API_ROOT_URL")
20+
if not settings.BUBBLE_API_KEY:
21+
raise RuntimeError("BUBBLE_API_KEY")
22+
23+
configure(
24+
data_api_root_url=settings.BUBBLE_DATA_API_ROOT_URL,
25+
api_key=settings.BUBBLE_API_KEY,
26+
)
27+
28+
yield
29+
30+
await close_clients()
31+
32+
33+
@pytest.fixture
34+
async def bubble_raw_client() -> AsyncGenerator[raw_client.RawClient]:
35+
"""Provide a raw client for testing the low-level API."""
36+
async with raw_client.RawClient() as client_instance:
37+
yield client_instance
38+
39+
40+
@pytest.fixture
41+
def typename() -> str:
42+
"""Return a test typename for integration tests."""
43+
# this typename should exist in the bubble app and should allow CRUD operations
44+
return "IntegrationTest"

0 commit comments

Comments
 (0)