testframework.clients.brain.tester.client_recorded module
A class representing the Test Client with recording for the tester .
This implementation of TestClient is to be exported to the testcase automation repo.
This class extends the TestBaseClient class and adds an annotation write to set contactor state.
- class testframework.clients.brain.tester.client_recorded.TestClient(tb: TestBench, default_timeout: int = 30, port: int = 1883, keep_alive: int = 300)
Bases:
BaseClient
Test client to be used in automatic tests cases. It has access to TestBench InfluxDB reflected in the name with_recorded.
Interactions with this client that are triggering state changes in the hardware (such as contactors) are recorded in the influxdb alongside the sensor data measured from the equipment under test.
Power Measurements in this client use L1, L2 and L3 as suffix for a single power line of the 3 phase connection
Not for all testbenches all client functionality is available! pvsystem, houseload, and solar are available for pvsystem benches wallbox and car are available for wallbox benches
To check if functionality of subobject is available clients subobject can be asserted in testcase like this:
>>> assert test_client.pvsystem is not None >>> test_client.pvsystem.turn_on_supply
- Usage:
Given a testbench from inventory model you can create a new TestClient with
TestClient(testbench, 30)
- The client provides an interface to resources on the testbench including
houseload
car
pv_system
grid
wallbox
solar
These can be accessed given an instance of
TestClient
with.car
for example:
Example
>>> def test_houseload_load1(self, testbench: TestBench): >>> brain = TestClient(testbench, default_timeout=30) >>> brain.car.connect() >>> assert brain.car.is_connected()
- car = None
- check_value(comp: Comparators, variable: PowerVariables, sampling_point: SamplingPoint, expected: list[float | int]) float
Checks last power measurement variable for sampling point with given comparator is true via MQTT.
- Parameters:
client (MQTTClient) – The MQTT client object.
comp (Comparators) – The comparator type, i.e Compartors.BIGGER.
variable (MQTTVariables) – The MQTT variable object, i.e MQTTVariables.POWERTOTAL.
sampling_point (SamplingPoint) – The sampling point object, i.e SamplingPoint.GRID
expected (list) – The expected value(s) to compare against.
- Returns:
The value received from MQTT client.
- Return type:
Any
- delete_dc_source_id() Response
Delete DC Source connection with ID on DC Source API
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_current(param: DcSourceParam) Response
Gets the current variable in Ampere specified in Enum for real DC source ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_dc_source_id() Response
Gets details of connected DC source with id
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_operation_mode() Response
Gets operation mode for DC source ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_remote() Response
Gets remote mode for DC source ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_standby() Response
Gets standby mode for DC source ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- get_voltage(param: DcSourceParam) Response
Gets the voltage variable in Volt specified in Enum for DC source ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- grid = None
- houseload = None
- post_current_mpp(current_mpp: float = 10) Response
Post creating a new serial connection to DC source
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- post_dc_source_http(ip_dc_source: str) Response
Post creating a new serial connection to DC source example for
`ip_dc_source`
is`http://dcsource1.lab.enpal.io/`
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- Parameters:
ip_dc_source (str) – Address of physical dc source ip or dns entry ok
- post_operation_mode(operation_mode: str = 'PVSIM') Response
Post operation mode of DC source with ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- post_remote(remote: DcSourceRemoteMode = DcSourceRemoteMode.OFA) Response
Post remote mode of DC source with ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- post_standby(standby: DcSourceStandbyMode = DcSourceStandbyMode.ON) Response
Post standby status of DC source with ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- post_voltage_mpp(voltage_mpp: float = 10) Response
Post creating a new serial connection to DC source
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- put_current_setting(current_setting: float = 10)
Put current setting in Ampere to DC source with ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- put_voltage_setting(voltage_setting: float = 10)
Put voltage setting in Volt to DC source with ID
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- pvsystem = None
- reset_contactors()
reset contactors of testbench client is connected to
- Returns:
request.response.json()
- reset_contactors_dc()
Reset contactors of the DC Source Bench which is connected to the Testbench the testclient is connected to.
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- Returns:
request.response.json()
- reset_dcsource_parameters() None
Reset DC source parameters to default values.
This will fail with “Base DC URL is not set, method not available” when testbench testclient is connected to has no DC source Connection
- set_contactor_state(contactor_point: ContactorPoints, contactor_state: ContactorState) ContactorStateResponse
This function shouldn’t be used directly unless you know what you’re doing, instead we refer to using the provided objects in this client, i.e [houseload, car, solar, pv_system, grid]
- Parameters:
contactor_point – (ContactorPoints) the contactor pin to manipulate
contactor_state – (ContactorState) the desired state to set on the pin
This sets contactor state for contactor point via testframework API.
- set_contactor_state_dc_bench(contactor_point: ContactorPoints, contactor_state: ContactorState) ContactorStateResponse
Sets contactor state for contactor point via testframework API on DC Source bench Test client is conneted to.
This function shouldn’t be used directly unless you know what you’re doing, instead we refer to using the provided objects in this client in this case solar
- Parameters:
contactor_point – (ContactorPoints) the contactor pin to manipulate
contactor_state – (ContactorState) the desired state to set on the pin
- solar = None
- wait_for_value(comp: Comparators, variable: PowerVariables, sampling_point: SamplingPoint, expected: list[Any], dur: float, start_time: float) float | None
Checks continuously power measurement variable for sampling point with given comparator until it’s true. When value was not met in specified duration via MQTT it returns an error.
- Parameters:
comp (Comparators) – The comparator object.
variable (PowerVariables) – The Power variable object.
sampling_point (SamplingPoint) – The sampling point object.
expected (list) – The expected value.
dur (float) – The duration to wait for the value.
start_time – The start time of the waiting period.
- Returns:
The elapsed time if the value is received within the duration, None otherwise.
- Return type:
Optional[float]
- wallbox = None