loadero_python.resources.test module

Loadero test resource.

Test resource is seperated into three parts

TestParams class describes test attributes

TestAPI class groups API operation with test resources.

Test class combines TestParams and TestAPI.

Single Test object coresponds to single test in Loadero.

class loadero_python.resources.test.Script(file_id: int | None = None, content: str | None = None, filepath: str | None = None)[source]

Bases: Serializable

Script describes a single Loadero test script.

from_dict(_: dict[str, Any]) Script[source]

Loads script from a dictionary. Never used. Required for serialization.

Args:

json_dict (dict[str, any]): JSON parsed as dictionary.

Returns:

Script: Script loaded from dictionary.

from_file(filepath: str) Script[source]

Loads Loadero script from file.

Args:

filepath (str): file path to script file

Returns:

Script: script loaded from file

read() Script[source]

Reads script from Loadero API.

Raises:

ValueError: If file_id is not specified.

APIException: If API call fails.

Returns:

Script: Script loaded from Loadero API.

to_dict() str[source]

Returns script content as a string. Used for serialization.

Returns:

str: Script content.

to_dict_full() str[source]

Returns script content as a string. Used for serialization.

Returns:

str: Script content.

class loadero_python.resources.test.Test(test_id: int | None = None, params: TestParams | None = None)[source]

Bases: LoaderoResource

Test class allows to perform CRUD operations on Loadero test resources.

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

The target Loadero test resource is determined by TestParams.

asserts(query_params: QueryParams | None = None) tuple[list[Assert], PaginationParams, dict[any, any]][source]

Read all asserts in test.

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

  • test_id

Args:

query_params (QueryParams, optional): Describes query parameters

Raises:

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

APIException: If API call fails.

Returns:

list[Assert]: List of asserts in test.

PaginationParams: Pagination parameters of request.

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

create() Test[source]

Creates new test with given data.

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

  • name

  • start_interval

  • participant_timeout

  • mode

  • increment_strategy

Raises:

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

APIException: If API call fails.

Returns:

Test: Created test resource.

delete() Test[source]

Deletes and existing test.

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

  • test_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Test: Deleted test resource.

duplicate(name: str) Test[source]

Duplicates and existing test.

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

  • test_id

Args:

name (str): New name for the duplicate test.

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Test: Duplicate test resource.

groups(query_params: QueryParams | None = None) tuple[list[Group], PaginationParams, dict[any, any]][source]

Read all groups in test.

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

  • test_id

Args:

query_params (QueryParams, optional): Describes query parameters

Raises:

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

APIException: If API call fails.

Returns:

list[Group]: List of groups in test.

PaginationParams: Pagination parameters of request.

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

launch() Run[source]

Launches test.

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

  • test_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Run: Launched test run.

participants(query_params: QueryParams | None = None) tuple[list[Participant], PaginationParams, dict[any, any]][source]

Read all participants in test.

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

  • test_id

Args:

query_params (QueryParams, optional): Describes query parameters

Raises:

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

APIException: If API call fails.

Returns:

list[Participant]: List of participants in test.

PaginationParams: Pagination parameters of request.

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

read() Test[source]

Reads information about an existing test.

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

  • test_id

Raises:

ValueError: If resource params do not sufficiently identify resource.

APIException: If API call fails.

Returns:

Test: Read test resource.

runs(query_params: QueryParams | None = None) tuple[list[Run], PaginationParams, dict[any, any]][source]

Read all runs in test.

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

  • test_id

Args:

query_params (QueryParams, optional): Describes query parameters

Raises:

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

APIException: If API call fails.

Returns:

list[Assert]: List of asserts in test.

PaginationParams: Pagination parameters of request.

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

update() Test[source]

Updates test with given parameters.

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

  • test_id

  • name

  • start_interval

  • participant_timeout

  • mode

  • increment_strategy

Raises:

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

APIException: If API call fails.

Returns:

Test: Updated test resource.

class loadero_python.resources.test.TestAPI[source]

Bases: object

TestAPI defines Loadero API operations for test resources.

static create(params: TestParams) TestParams[source]

Create a new test resource.

Args:

params (TestParams): Describes the test resource to be created.

APIException: If API call fails.

Returns:

TestParams: Created participant resource.

static delete(params: TestParams) TestParams[source]

Delete an existing test resource.

Args:

params (TestParams): Describes the test resource to delete.

Raises:

Exception: TestParams.test_id was not defined.

APIException: If API call fails.

Returns:

TestParams: Deleted test resource.

static duplicate(params: TestParams, name: str) TestParams[source]

Created a duplicate test resource from an existing test resource.

Args:
params (TestParams): Describe the test resources to duplicate and

the name of the duplicate test resource.

Raises:

Exception: TestParams.test_id was not defined.

APIException: If API call fails.

Returns:

TestParams: Duplicated test resource.

static read(params: TestParams) TestParams[source]

Read an existing test resource.

Args:

params (TestParams): Describes the test resource to read.

Raises:

Exception: TestParams.test_id was not defined.

APIException: If API call fails.

Returns:

TestParams: Read test resource.

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

Read all test resources.

Raises:

APIException: If API call fails.

Returns:

PagedResponse: Paged response of participant resources.

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

Build test resource url route.

Args:

test_id (int, optional): Test resource id. Defaults to None. If omitted the route will point to all test resources.

Returns:

str: Route to test resource/s.

static update(params: TestParams) TestParams[source]

Update an existing test resource.

Args:

params (TestParams): Describe the test resource to update.

Raises:

Exception: TestParams.test_id was not defined.

APIException: If API call fails.

Returns:

TestParams: Updated test resource.

class loadero_python.resources.test.TestFilterKey(value)[source]

Bases: FilterKey

TestFilterKey is an enum of all filter keys for test read all API operation.

INCREMENT_STRATEGY = 'filter_increment_strategy'
NAME = 'filter_name'
PARTICIPANT_TIMEOUT_FROM = 'filter_participant_timeout_from'
PARTICIPANT_TIMEOUT_TO = 'filter_participant_timeout_to'
START_INTERVAL_FROM = 'filter_start_interval_from'
START_INTERVAL_TO = 'filter_start_interval_to'
TEST_MODE = 'filter_test_mode'
class loadero_python.resources.test.TestParams(test_id: int | None = None, name: str | None = None, start_interval: int | None = None, participant_timeout: int | None = None, mode: TestMode | None = None, increment_strategy: IncrementStrategy | None = None, mos_test: bool | None = None, script: Script | None = None)[source]

Bases: LoaderoResourceParams

TestParams describes single Loadero test resources attributes.

TestParams has a builder pattern for writeable attributes.

property created: datetime

Time when test was created.

Returns:

datetime: Time when test was created.

property deleted: bool

Is test deleted.

Returns:

bool: Is test deleted.

property group_count: int

Number of groups in test.

Returns:

int: Number of groups in test.

property participant_count: int

Number of participants in test.

Returns:

int: Number of participants in test.

property script: Script

Retrive the test script.

Returns:

Script: Test script.

property updated: datetime

Time when test was last updated.

Returns:

datetime: Time when test was last updated.

with_id(test_id: int) TestParams[source]

Set test id.

Args:

test_id (int): Test id.

Returns:

TestParams: TestParams with test id set.

with_increment_strategy(increment_strategy: IncrementStrategy) TestParams[source]

Set test increment strategy.

Args:

increment_strategy (IncrementStrategy): Test increment strategy.

Returns:

TestParams: TestParams with test increment strategy set.

with_mode(test_mode: TestMode) TestParams[source]

Set test mode.

Args:

test_mode (TestMode): Test mode.

Returns:

TestParams: TestParams with test mode set.

with_mos_test(mos_test: bool) TestParams[source]

Set test MOS test.

Args:

mos_test (bool): Test MOS test.

Returns:

TestParams: TestParams with test MOS test set.

with_name(name: str) TestParams[source]

Set test name.

Args:

name (str): Test name.

Returns:

TestParams: TestParams with test name set.

with_participant_timeout(participant_timeout: int) TestParams[source]

Set test participant timeout.

Args:

participant_timeout (int): Test participant timeout.

Returns:

TestParams: TestParams with test participant timeout set.

with_script(script: Script) TestParams[source]

Set test script.

Args:

script (Script): The test script.

Returns:

TestParams: TestParams with test script set.

with_start_interval(start_interval: int) TestParams[source]

Set test start interval.

Args:

start_interval (int): Test start interval.

Returns:

TestParams: TestParams with test start interval set.