testframework.clients.ops packageο
Operation Container Source classes
Items added into __all__ will be importable with from testframework.clients.ops import <ITEM>
- class testframework.clients.ops.OpsClient(tb: TestBench, default_timeout: int)ο
Bases:
OpsBaseClient
Ops Client class for testing operations.
Also known as the βNo Brainerβ client
This class inherits from the OpsBaseClient class and provides additional methods that are related to managing the OpsContainer in a test context
If youβre intending to write tests against a testbench with testbrain on it, we recommend using the OpsClientRecorded class, which adds the functionality of annototations in Grafana. usage:
Example
>>> from testframework.clients.ops.tester.tester_client_recorded import OpsClientRecorded
- assert_response_success(response: Response) None ο
Asserts that the response is successful. :param response: The response object to be validated. :type response: requests.Response
- Returns:
If function returns then assertion passes
- Return type:
None
- Raises:
AssertionError β If the response status code is not in the range of 2xx.
- assert_sensor_value_matches(sensor_name: GlobalSensorName, expected: str | int)ο
Check if the sensor value matches the expected value.
- Parameters:
ops_interface (OpsInterface) β The OpsInterface object used to interact with the API.
sensor_name (GlobalSensorName) β The name of the sensor.
expected (str | int) β The expected value of the sensor.
- Raises:
AssertionError β If the sensor value does not match the expected value or if the API call fails.
- check_battery(battery_level_lowerl: float = 30, battery_level_upperl: float = 85)ο
Check if the battery charge level is within the desired limits.
- Parameters:
ops_interface (OpsInterface) β The interface object for interacting with the ops system.
battery_level_lowerl (float, optional) β The lower limit for the battery charge level. Defaults to 30.
battery_level_upperl (float, optional) β The upper limit for the battery charge level. Defaults to 85.
- Raises:
AssertionError β If the validation check for the value fails.
- check_errors()ο
Checks that no error codes are present in the system.
- Parameters:
ops_interface (OpsInterface) β The interface for interacting with the system.
- Raises:
AssertionError β If getting the error state from the API was not successful.
- check_preconditions() None ο
Executes all available precondition checks. - check_properties_inverter - check_properties_battery - check_default_params - check_errors - check_battery :param ops_interface: The interface for interacting with the operations. :type ops_interface: OpsInterface
- Returns:
None
- check_properties_battery()ο
Validate battery properties in testbench with reference value
- check_properties_dongle()ο
Validate dongle properties in testbench with reference value.
- Raises:
AssertionError β If the reference data of the testbench is missing or if the serial number is not matching.
- check_properties_inverter()ο
Checks the properties of the inverter device against the inventory data. If any of the properties do not match the inventory data, an AssertionError is raised.
Args:
- Raises:
AssertionError β If any of the properties do not match the reference data.
- check_value(value: float | int, comp: Comparators, expected: list[float | int], break_on_fail: bool | None = False) float ο
Checks value with given comparator.
- Parameters:
value (float | int) β The value to be checked.
comp (Comparators) β The comparator to be used for comparison.
expected (List[float | int]) β The expected values for comparison.
break_on_fail (Optional[bool]) β If True, the test will stop immediately on failure. If False or None, the test will continue and log the failure at the end. Defaults to None.
- Returns:
The original value.
- Return type:
float
- ensure_default_params() None ο
Check that default parameters are applied from Ops API and apply them if not.
This function sends a POST request to the Ops API to set the default parameters. If the API response is 200, it means that the default parameters were successfully set. If the API response is not 200, it raises an exception.
- Parameters:
ops_interface (OpsInterface) β An instance of the OpsInterface class.
- Raises:
AssertionError β If the API response is not 200.
- get_manufacturer(actual_device_properties: list[DeviceProperties]) str ο
Fetches the manufacturer from the device properties.
- Parameters:
actual_device_properties (list) β A list of device properties.
- Returns:
The manufacturer of the device.
- Return type:
str
- Raises:
AssertionError β If the manufacturer is None.
- run_validation_check(value, comp, expected)ο
Runs a validation check on the given value using the specified comparison operator and expected value.
- Parameters:
value β The value to be validated.
comp β The comparison operator to be used for validation.
expected β The expected value or range of values for comparison.
- Returns:
None
- Raises:
AssertionError β If the validation check fails.
Subpackagesο
- testframework.clients.ops.tester package
OpsClient
OpsClient.assert_response_success()
OpsClient.assert_sensor_value_matches()
OpsClient.check_battery()
OpsClient.check_errors()
OpsClient.check_preconditions()
OpsClient.check_properties_battery()
OpsClient.check_properties_dongle()
OpsClient.check_properties_inverter()
OpsClient.check_value()
OpsClient.ensure_default_params()
OpsClient.get_manufacturer()
OpsClient.run_validation_check()
- Submodules
- testframework.clients.ops.tester.modbus_container module
- testframework.clients.ops.tester.tester_client module
OpsClient
OpsClient.assert_response_success()
OpsClient.assert_sensor_value_matches()
OpsClient.check_battery()
OpsClient.check_errors()
OpsClient.check_preconditions()
OpsClient.check_properties_battery()
OpsClient.check_properties_dongle()
OpsClient.check_properties_inverter()
OpsClient.check_value()
OpsClient.ensure_default_params()
OpsClient.get_manufacturer()
OpsClient.run_validation_check()
- testframework.clients.ops.tester.tester_client_recorded module
- testframework.clients.ops.tester.wallbox module
Phase
RemoteStartStopStatus
ResetTypes
ThreePhaseConnector
ThreePhaseElectricalProperties
Wallbox
Wallbox.get_charge_mode()
Wallbox.get_charge_point_charge_flow_w()
Wallbox.get_charge_point_charge_percentage()
Wallbox.get_charge_point_details()
Wallbox.get_charge_point_phase_details()
Wallbox.get_charge_point_power_offered_w()
Wallbox.get_charge_point_power_requested_w()
Wallbox.get_charge_status()
Wallbox.get_electrical_properties()
Wallbox.is_connected()
Wallbox.set_charge_mode()
Wallbox.set_charge_point_charge_value()
Wallbox.start_charging()
Wallbox.stop_charging()
WallboxChargeMode
WallboxChargeStatus
Submodulesο
- testframework.clients.ops.api_model module
Action
DeviceAttribute
DeviceClassEnum
DeviceProperties
DeviceProperties.attributes
DeviceProperties.deviceClass
DeviceProperties.deviceId
DeviceProperties.eTag
DeviceProperties.identifiers
DeviceProperties.manufacturer
DeviceProperties.model_computed_fields
DeviceProperties.model_config
DeviceProperties.model_fields
DeviceProperties.serialNumber
DeviceProperties.timeStampUtc
DeviceProperties.type
ElectroUnitEnum
ElectroUnitEnum.A
ElectroUnitEnum.Ah
ElectroUnitEnum.Celcius
ElectroUnitEnum.Hz
ElectroUnitEnum.KiloOhm
ElectroUnitEnum.MegaOhm
ElectroUnitEnum.Minutes
ElectroUnitEnum.None_
ElectroUnitEnum.Ohm
ElectroUnitEnum.Percent
ElectroUnitEnum.V
ElectroUnitEnum.VA
ElectroUnitEnum.W
ElectroUnitEnum.Wh
ElectroUnitEnum.kVA
ElectroUnitEnum.kVAR
ElectroUnitEnum.kW
ElectroUnitEnum.kWh
ElectroUnitEnum.mA
ErrorResponse
GridControlResponse
HeartbeatRequest
LoadLimitRequest
MeasurementUnitType
MeasurementUnitType.A
MeasurementUnitType.Ah
MeasurementUnitType.Celcius
MeasurementUnitType.Hz
MeasurementUnitType.KiloOhm
MeasurementUnitType.MegaOhm
MeasurementUnitType.Minutes
MeasurementUnitType.None_
MeasurementUnitType.Ohm
MeasurementUnitType.Percent
MeasurementUnitType.V
MeasurementUnitType.VA
MeasurementUnitType.W
MeasurementUnitType.Wh
MeasurementUnitType.kVA
MeasurementUnitType.kW
MeasurementUnitType.kWh
MeasurementUnitType.mA
NumberDataPoint
PowerLimitType
PvActionRequest
SensorValue
- testframework.clients.ops.base_client module
OpsBaseClient
OpsBaseClient.url_base
OpsBaseClient.logger
OpsBaseClient.default_timeout
OpsBaseClient.start_time
OpsBaseClient.get_all_global_sensor_name()
OpsBaseClient.get_device_properties()
OpsBaseClient.get_global_sensor_name()
OpsBaseClient.get_pv_sensor_value()
OpsBaseClient.post_device_defaults()
OpsBaseClient.post_pv_action()
OpsBaseClient.put_grid_control_lpc()
OpsBaseClient.put_grid_control_lpp()
OpsBaseClient.remove_grid_control_lpp()
OpsBaseClient.wait_for_sensor_value()