-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
149 additions
and
37 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import asyncio | ||
|
||
import httpx | ||
|
||
from horreum import new_horreum_client, ClientConfiguration | ||
|
||
DEFAULT_CONNECTION_TIMEOUT: int = 30 | ||
DEFAULT_REQUEST_TIMEOUT: int = 100 | ||
|
||
base_url = "http://localhost:8080" | ||
username = "user" | ||
password = "secret" | ||
|
||
expected_server_version = "0.13.0" | ||
expected_n_schemas = 2 | ||
expected_n_tests = 1 | ||
enable_assertions = False | ||
|
||
|
||
async def example(): | ||
timeout = httpx.Timeout(DEFAULT_REQUEST_TIMEOUT, connect=DEFAULT_CONNECTION_TIMEOUT) | ||
http_client = httpx.AsyncClient(timeout=timeout, http2=True, verify=False) | ||
client = await new_horreum_client(base_url, client_config=ClientConfiguration(http_client=http_client)) | ||
|
||
server_version = await client.raw_client.api.config.version.get() | ||
print(server_version) | ||
if enable_assertions: | ||
assert server_version.version == expected_server_version | ||
|
||
get_schemas = await client.raw_client.api.schema.get() | ||
print(get_schemas.count) | ||
if enable_assertions: | ||
assert get_schemas.count == expected_n_schemas | ||
|
||
get_tests = await client.raw_client.api.test.get() | ||
print(get_tests.count) | ||
if enable_assertions: | ||
assert get_tests.count == expected_n_tests | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(example()) |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from horreum.configs import HorreumCredentials, ClientConfiguration | ||
from horreum.horreum_client import new_horreum_client | ||
|
||
__all__ = [ | ||
new_horreum_client | ||
new_horreum_client, | ||
HorreumCredentials, | ||
ClientConfiguration | ||
] |
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,21 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
import httpx | ||
from kiota_abstractions.request_option import RequestOption | ||
|
||
|
||
@dataclass(frozen=True) | ||
class HorreumCredentials: | ||
username: str = None | ||
password: str = None | ||
|
||
|
||
@dataclass | ||
class ClientConfiguration: | ||
# inner http async client that will be used to perform raw requests | ||
http_client: Optional[httpx.AsyncClient] = None | ||
# if true, set default middleware on the provided client | ||
use_default_middlewares: bool = True | ||
# if set use these options for default middlewares | ||
options: Optional[dict[str, RequestOption]] = None |
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