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
- grid = Noneο
- houseload = Noneο
- pvsystem = Noneο
- 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.
- 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ο