loadero_python.resources.assert_resource module

Loadero assert resource.

Assert resource is seperated into three parts

AssertParams class describes assert attributes

AssertAPI class that groups all API operations with assert resource.

Assert class that combines AssertParams and AssertAPI.

Single Assert object coresponds to single assert in Loadero.

class loadero_python.resources.assert_resource.Assert(assert_id: int | None = None, test_id: int | None = None, params: AssertParams | None = None)[source]

Bases: LoaderoResource

Assert class allows to perform CRUD manipulatons on a single Loadero assert resource.

APIClient must be previously initialized with a valid Loadero access token.

The target Loadero assert resource is determined by AssertParams.

create() Assert[source]

Creates new assert with given data.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • expected

  • operator

  • path

Raises:

ValueError: If resource params do not sufficiently identify parent resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

Assert: Created assert resource.

delete() None[source]

Deletes and existing assert.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • assert_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

duplicate() Assert[source]

Duplicates and existing assert.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • assert_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Assert: Duplicate instance of assert.

preconditions(query_params: QueryParams | None = None) list[AssertPrecondition][source]

Read all preconditions of assert.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • assert_id

Args:

query_params (QueryParams, optional): Describes query parameters

Raises:

ValueError: Assert.params.test_id must be a valid int

ValueError: Assert.params.assert_id must be a valid int

APIException: If API call fails.

Returns:

list[AssertPrecondition]: List of all preconditions of assert

PaginationParams: Pagination parameters of request.

dict[any, any]: Filters applied to in request.

read() Assert[source]

Reads information about an existing assert.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • assert_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Assert: Read assert resource.

update() Assert[source]

Updates assert with given parameters.

Required attributes of params field that need to be populated, otherwise the method will raise an exception:

  • test_id

  • assert_id

  • expected

  • operator

  • path

Raises:

ValueError: If resource params do not sufficiently identify resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

Assert: Updated assert resource.

class loadero_python.resources.assert_resource.AssertAPI[source]

Bases: object

AssertAPI defines Loadero API operations for assert resources.

static create(params: AssertParams) AssertParams[source]

Create a new assert resource.

Args:

params (AssertParams): Describes the assert resource to be created.

Raises:

ValueError: If resource params do not sufficiently identify parent resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

AssertParams: Created assert resource.

static delete(params: AssertParams) None[source]

Delete an existing assert resource.

Args:

params (AssertParams): Describes the assert resource to delete.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

static duplicate(params: AssertParams) AssertParams[source]

Duplicate an existing assert resource.

Args:

params (AssertParams): Describe the assert resource to duplicate and the name of duplicate assert resource.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

AssertParams: Duplicate assert resource.

static read(params: AssertParams) AssertParams[source]

Read an existing assert resource.

Args:

params (AssertParams): Describes the assert resource to read.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

AssertParams: Read assert resource.

static read_all(test_id: int, query_params: QueryParams | None = None) PagedResponse[source]

Read all assert resources.

Args:

test_id (int): Parent test resource id. query_params (QueryParams, optional): Describes query parameters.

Raises:

APIException: If API call fails.

Returns:

PagedResponse: Paged response of assert resources.

static route(test_id: int, assert_id: int | None = None) str[source]

Build assert resource url route.

Args:

test_id (int): Test resource id.

assert_id (int, optional): Assert resource id. Defaults to None. If omitted the route will point to all assert resources.

Returns:

str: Route to assert resource/s.

static update(params: AssertParams) AssertParams[source]

Update an existing assert resource.

Args:

params (AssertParams): Describes the assert resource to update.

Raises:

ValueError: If resource params do not sufficiently identify resource or resource params required attributes are None.

APIException: If API call fails.

Returns:

AssertParams: Updated assert resource.

class loadero_python.resources.assert_resource.AssertFilterKey(value)[source]

Bases: FilterKey

AssertFilterKey is an enum of all filter keys for assert read all API operation.

EXPECTED = 'filter_expected'
OPERATOR = 'filter_operator'
PATH = 'filter_path'
class loadero_python.resources.assert_resource.AssertParams(assert_id: int | None = None, test_id: int | None = None, path: MetricPath | None = None, operator: Operator | None = None, expected: str | None = None)[source]

Bases: LoaderoResourceParams

AssertParams describes single Loadero assert resources attributes.

AssertParams has a builder pattern for assert resources writable attributes.

property created: datetime

Time when assert was created.

Returns:

datetime: Time when assert was created.

in_test(test_id: int) AssertParams[source]

Set parent test id.

Args:

test_id (int): Test id.

Returns:

AssertParams: Assert params with set parent test id.

property updated: datetime

Time when assert was last updated.

Returns:

datetime: Time when assert was last updated.

with_expected(expected: str) AssertParams[source]

Set assert expected value.

Args:

expected (str): Expected value.

Returns:

AssertParams: Assert params with set expected value.

with_id(assert_id: int) AssertParams[source]

Set assert id.

Args:

assert_id (int): Assert id.

Returns:

AssertParams: Assert params with set id.

with_operator(operator: Operator) AssertParams[source]

Set assert operator.

Args:

operator (Operator): Operator.

Returns:

AssertParams: Assert params with set operator.

with_path(path: MetricPath) AssertParams[source]

Set assert metric path.

Args:

path (MetricPath): Metric path.

Returns:

AssertParams: Assert params with set metric path.