testframework.clients.ops.base_client moduleο
This module defines the OpsBaseClient class, which interfaces with the OpsAPI This should contain core methods to communicate with the OpsAPI but additional logic should be created in the inherited classes: - FrameworkOpsClient (framework_client.py) - OpsClient (tester_client.py)
- class testframework.clients.ops.base_client.OpsBaseClient(url: str, default_timeout: int)ο
Bases:
object
The base client for interacting with the Operations Container API.
This class provides methods for making HTTP requests to the Operations Container API, such as GET, POST, PUT, and DELETE requests. It also includes methods for retrieving global sensor data, PV sensor data, device properties, and performing various operations on the Operations Container.
- url_baseο
The base URL of the Operations Container API.
- Type:
str
- loggerο
The logger object for logging debug and error messages.
- Type:
logging.Logger
- default_timeoutο
The default timeout value for HTTP requests.
- Type:
int
- start_timeο
Start time of the client
- Type:
time
- async get_all_global_sensor_name(global_sensor_name: type[GlobalSensorName | GlobalSensorNameInverterBatch1 | GlobalSensorNameInverterBatch2 | GlobalSensorNameInverterBatch3 | GlobalSensorNameInverterBatch4 | GlobalSensorNameWallboxBatch1 | GlobalSensorNameWallboxBatch2 | GlobalSensorNameWallboxBatch3 | GlobalSensorNameWallboxBatch4]) list[NumberDataPoint | None] ο
Async method to get all global sensor names from the provided enum. This iterates over the enumβs values and makes parallel requests to the OpsApi
- Parameters:
global_sensor_name (list) β A list of global sensor names.
- Returns:
A list of parsed number data points.
- Return type:
list[NumberDataPoint]
- get_device_properties() list[DeviceProperties | None] ο
Returns properties of all devices i.e inverter, battery, edge device etc. :raises ValidationError: If failed to validate response from API.
- Returns:
An instance of the DeviceProperties class containing the properties of all devices.
- Return type:
- get_global_sensor_name(sensor_name: GlobalSensorName | GlobalSensorNameInverterBatch1) NumberDataPoint ο
Sends a GET request for the value of Global Sensor Name of Operation Container.
- Parameters:
sensor_name (GlobalSensorName) β The name of the global sensor.
- Raises:
ValidationError β if failed to validate response from API
- Returns:
The value of the global sensor as a NumberDataPoint object.
- Return type:
- get_pv_sensor_value(sensor_name: GlobalSensorName) SensorValue ο
Sends a GET request for PV Sensor value by Name from Operation Container.
- Parameters:
sensor_name (GlobalSensorName) β The name of the sensor.
- Raises:
Validation Error if failed β
- Returns:
The value of the sensor.
- Return type:
- post_device_defaults() bool ο
Sends a POST request to apply default parameters of the system.
- Raises:
ValueError β If the OpsApi fails with a status code other than 200, or if there is an error in the response.
Exception β If there is an exception while processing the response.
- Returns:
True if the default parameters are successfully applied, False otherwise.
- Return type:
bool
- post_pv_action(pv_action: PvActionRequest) float | ErrorResponse ο
Sends a POST request to the Pv Action endpoint.
- Parameters:
pv_action (PvActionRequest) β The PvActionRequest object containing the data for the request.
- Raises:
ValueError β If the response code is not 200 or 400.
- Returns:
The start time of the request if successful, or an ErrorResponse object if there was an error.
- Return type:
float | ErrorResponse
- put_grid_control_lpc(data: LoadLimitRequest) GridControlResponse ο
Puts Limit Power Consumption to operation container.
- Parameters:
data (LoadLimitRequest) β The data containing the load limit request.
- Raises:
ValidationError β if failed to parse response from API.
- Returns:
The response from the operation container.
- Return type:
- put_grid_control_lpp(data: LoadLimitRequest) GridControlResponse ο
Puts Limit Power Production to operation container.
- Parameters:
data (LoadLimitRequest) β The data containing the load limit request.
- Raises:
ValidationError β If failed to parse response from API
- Returns:
The response from the operation container.
- Return type:
- remove_grid_control_lpp(timeout: int | None) GridControlResponse ο
Removes the lpp setting of the Operations Container.
- Raises:
ValidationError β
- Returns:
A GridControlResponse object representing the response from the API.
- wait_for_sensor_value(sensor_type: Type[float | str], sensor_name: GlobalSensorName, expected_values: list[int | float | str], comparator: Comparators, timeout_seconds: int, success_hold_seconds: int, delay_seconds: int = 1) str | float ο
Waits for a specified SensorValue (modbus register) to fulfill the provided parameters. The value needs to remain within parameters for a specified amount of time for the method to succeed.
- Parameters:
sensor_type (Type[str|float]) β Return type of the associated modbus register (string | int | float)
sensor_name (GlobalSensorName) β The sensor value to monitor
expected_values (list) β Expected value (range) as required by the specified comparator
comparator (Comparators) β Comparator to apply between the expected and received value
timeout_seconds (int) β Maximum wait time in seconds. This includes the success-hold time.
success_hold_seconds (int) β Time in seconds for which the value has to continuously satisfy the comparator condition.
delay_seconds (int, optional) β Frequency in which to check for value changes. Defaults to 1.
- Raises:
SensorValueTimeoutException β Raised if the value does not meet the expected constraints in the given time.
- Returns:
value returned by the register
- Return type:
sensor_type(str | float)