athena.client
Athena
Main api for executed modules
Attributes:
Name | Type | Description |
---|---|---|
fixture |
Fixture
|
provider for test fixtures |
infix |
Fixture
|
wrapper for |
cache |
Cache
|
persistent key ( |
context |
Context
|
information about the runtime environment of the module |
fake |
Fake
|
generate randomized data |
variable |
ResourceFacade
|
get a variable by name |
secret |
ResourceFacade
|
get a secret by name |
Source code in athena/client.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
client(base_build_request=None, name=None)
Create a new client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_build_request |
Callable[[RequestBuilder], [RequestBuilder]] | None
|
Function to configure all requests sent by the client. |
None
|
name |
str | None
|
Optional name for client. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Client |
Client
|
The configured client. |
Source code in athena/client.py
trace(subject=None)
Get the full AthenaTrace
for a given request or response trace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subject |
AthenaTrace | RequestTrace | ResponseTrace | None
|
The trace to lookup. If no trace is provided, will return the most recent trace. |
None
|
Returns:
Name | Type | Description |
---|---|---|
AthenaTrace |
AthenaTrace
|
The full |
Example:
def run(athena: Athena):
response = athena.client().get('https://example.com')
trace = athena.trace(response)
print(f'request completed in {trace.elapsed} seconds')
Source code in athena/client.py
traces()
Get all AthenaTrace
s from the lifetime of this instance.
Returns:
Type | Description |
---|---|
list[AthenaTrace]
|
list[AthenaTrace]: List of traces. |
Context
Information about the runtime environment of the module
Attributes:
Name | Type | Description |
---|---|---|
environment |
str
|
name of environment |
module_name |
str
|
name of the module |
module_path |
str
|
path to the module |
root_path |
str
|
path to root of athena directory |
Source code in athena/client.py
ResourceFacade
Facade to interact with resource files.
Attributes:
Name | Type | Description |
---|---|---|
int |
TypedResourceFacade
|
attempt to cast to int when retrieving value |
bool |
TypedResourceFacade
|
attempt to cast to bool when retrieving value |
str |
TypedResourceFacade
|
attempt to cast to str when retrieving value |
float |
TypedResourceFacade
|
attempt to cast to float when retrieving value |
Source code in athena/client.py
get(key, default=None)
Get value by name. Returns default value if key cannot be found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
Name of resource to retrieve. |
required |
default |
_resource_value_type | None
|
Default value |
None
|
Returns:
Type | Description |
---|---|
_resource_value_type | None
|
_resource_value_type | None: value |
Source code in athena/client.py
TypedResourceFacade
Bases: Generic[T]
Typed facade to interact with resource files.
Source code in athena/client.py
get(key, default=None)
Get value by name. Returns default value if key cannot be found or value is the wrong type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
Name of resource to retrieve. |
required |
default |
_resource_value_type | None
|
Default value |
None
|
Returns:
Type | Description |
---|---|
T | None
|
_resource_value_type | None: value |
Source code in athena/client.py
jsonify(item, *args, **kwargs)
Runs objects through json.dumps, with an encoder for athena objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Any
|
The item to json encode. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The json string |
Example:
from athena.client import Athena, jsonify
def run(athena: Athena):
athena.client().get("http://haondt.com")
traces = athena.traces()
print(jsonify(traces, indent=4))