-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration): add integration tests with a real server
This commit adds integration tests that will check if the SDK works when talking to a real server.
- Loading branch information
1 parent
a41587a
commit 36526d9
Showing
6 changed files
with
108 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kind: Test | ||
body: Add integration tests with a real server | ||
time: 2024-06-18T18:51:02.089246+02:00 |
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
Empty file.
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,55 @@ | ||
from typing import AsyncIterator, Iterator | ||
|
||
import pytest | ||
|
||
from dbtsl.api.graphql.client.asyncio import AsyncGraphQLClient | ||
from dbtsl.api.graphql.client.sync import SyncGraphQLClient | ||
|
||
from ..conftest import Credentials | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
async def async_client(credentials: Credentials) -> AsyncIterator[AsyncGraphQLClient]: | ||
client = AsyncGraphQLClient( | ||
environment_id=credentials.environment_id, | ||
auth_token=credentials.token, | ||
server_host=credentials.host, | ||
) | ||
async with client.session(): | ||
yield client | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def sync_client(credentials: Credentials) -> Iterator[SyncGraphQLClient]: | ||
client = SyncGraphQLClient( | ||
environment_id=credentials.environment_id, | ||
auth_token=credentials.token, | ||
server_host=credentials.host, | ||
) | ||
with client.session(): | ||
yield client | ||
|
||
|
||
def test_sync_client_lists_metrics_and_dimensions(sync_client: SyncGraphQLClient) -> None: | ||
metrics = sync_client.metrics() | ||
assert len(metrics) > 0 | ||
dims = sync_client.dimensions(metrics=[metrics[0].name]) | ||
assert len(dims) > 0 | ||
|
||
|
||
async def test_async_client_lists_metrics_and_dimensions(async_client: AsyncGraphQLClient) -> None: | ||
metrics = await async_client.metrics() | ||
assert len(metrics) > 0 | ||
dims = await async_client.dimensions(metrics=[metrics[0].name]) | ||
assert len(dims) > 0 | ||
|
||
|
||
async def test_async_client_query_works(async_client: AsyncGraphQLClient) -> None: | ||
metrics = await async_client.metrics() | ||
assert len(metrics) > 0 | ||
table = await async_client.query( | ||
metrics=[metrics[0].name], | ||
group_by=["metric_time"], | ||
limit=1, | ||
) | ||
assert len(table) > 0 |