testframework.clients.brain packageο
Init Brain Client module for Framework and TestCase Automation
- class testframework.clients.brain.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ο
Subpackagesο
- testframework.clients.brain.tester package
TestClient
- Submodules
- testframework.clients.brain.tester.car module
- testframework.clients.brain.tester.client_recorded module
- testframework.clients.brain.tester.grid module
GridConnection
GridConnection.connect()
GridConnection.disconnect()
GridConnection.get_current_l1()
GridConnection.get_current_l2()
GridConnection.get_current_l3()
GridConnection.get_frequency()
GridConnection.get_power_l1()
GridConnection.get_power_l2()
GridConnection.get_power_l3()
GridConnection.get_power_total()
GridConnection.get_total_energy_export()
GridConnection.get_total_energy_import()
GridConnection.get_voltage_l1()
GridConnection.get_voltage_l2()
GridConnection.get_voltage_l3()
- testframework.clients.brain.tester.houseload module
HouseLoadConnection
HouseLoadConnection.get_current_l1()
HouseLoadConnection.get_current_l2()
HouseLoadConnection.get_current_l3()
HouseLoadConnection.get_frequency()
HouseLoadConnection.get_power_l1()
HouseLoadConnection.get_power_l2()
HouseLoadConnection.get_power_l3()
HouseLoadConnection.get_power_total()
HouseLoadConnection.get_power_variable()
HouseLoadConnection.get_total_energy_export()
HouseLoadConnection.get_total_energy_import()
HouseLoadConnection.get_voltage_l1()
HouseLoadConnection.get_voltage_l2()
HouseLoadConnection.get_voltage_l3()
HouseLoadConnection.turn_off_all_loads()
HouseLoadConnection.turn_off_loadl1()
HouseLoadConnection.turn_off_loadl2()
HouseLoadConnection.turn_off_loadl3()
HouseLoadConnection.turn_on_all_loads()
HouseLoadConnection.turn_on_loadl1()
HouseLoadConnection.turn_on_loadl2()
HouseLoadConnection.turn_on_loadl3()
- testframework.clients.brain.tester.pvsystem module
PvsystemConnection
PvsystemConnection.get_current_l1()
PvsystemConnection.get_current_l2()
PvsystemConnection.get_current_l3()
PvsystemConnection.get_frequency()
PvsystemConnection.get_power_l1()
PvsystemConnection.get_power_l2()
PvsystemConnection.get_power_l3()
PvsystemConnection.get_power_total()
PvsystemConnection.get_total_energy_export()
PvsystemConnection.get_total_energy_import()
PvsystemConnection.get_voltage_l1()
PvsystemConnection.get_voltage_l2()
PvsystemConnection.get_voltage_l3()
PvsystemConnection.turn_off_supply()
PvsystemConnection.turn_on_supply()
- testframework.clients.brain.tester.solar module
- testframework.clients.brain.tester.wallbox module
WallboxConnection
WallboxConnection.get_current_l1()
WallboxConnection.get_current_l2()
WallboxConnection.get_current_l3()
WallboxConnection.get_frequency()
WallboxConnection.get_power_l1()
WallboxConnection.get_power_l2()
WallboxConnection.get_power_l3()
WallboxConnection.get_power_total()
WallboxConnection.get_total_energy_export()
WallboxConnection.get_total_energy_import()
WallboxConnection.get_voltage_l1()
WallboxConnection.get_voltage_l2()
WallboxConnection.get_voltage_l3()