-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (31 loc) · 942 Bytes
/
utils.py
File metadata and controls
38 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests_mock
from requests.auth import AuthBase
import typing as t
from flareio import FlareApiClient
def get_test_client(
*,
tenant_id: t.Optional[int] = None,
authenticated: bool = True,
api_domain: t.Optional[str] = None,
_enable_beta_features: bool = False,
_auth: t.Optional[AuthBase] = None,
) -> FlareApiClient:
client = FlareApiClient(
api_key="test-api-key",
tenant_id=tenant_id,
api_domain=api_domain,
_enable_beta_features=_enable_beta_features,
_auth=_auth,
)
if authenticated:
with requests_mock.Mocker() as mocker:
mocker.register_uri(
"POST",
f"https://{client._api_domain}/tokens/generate",
json={
"token": "test-token-hello",
},
status_code=200,
)
client.generate_token()
return client