Features
This section describes all features that are shipped with this package.
Scenario Features
- class balderhub.battery.lib.scenario_features.BatteryLevelReader(**kwargs)
Bases:
FeatureScenario level feature that provides a interface for reading the battery level
- property expected_accuracy_plusminus_percent: float
- Returns:
returns the expected accuracy in percent (+/- from expected value)
- read_current_battery_level() float | None
reads the current battery level (return None if the device is powered off)
- class balderhub.battery.lib.scenario_features.BatterySimFeature(**kwargs)
Bases:
FeatureBase scenario level feature that provides bindings to a device that can simulate batteries
- property discharge_characteristic: BaseBatteryDischargeCharacteristic
- Returns:
returns a specific Battery Characteristic that describes the behavior of the battery discharge
- get_current_active_level() float
This method returns the current setted battery level. :return: the current setted battery level
- set_to(battery_level: float)
This method sets the battery level to the provided value (needs to be between 0 and 1) :param battery_level: :return:
- class balderhub.battery.lib.scenario_features.BatteryTestCriteriaConfig(**kwargs)
Bases:
FeatureTest Criteria Configuration object to define criteria the test should use
- property validation_with_battery_levels: list[float]
- Returns:
returns a list of battery levels the test should use
- class balderhub.battery.lib.scenario_features.DeviceActivityFeature(**kwargs)
Bases:
FeatureScenario Level feature that allows to check if a device is active or inactive.
- cleanup() None
Cleans up the environment to be able to run the
DeviceActivityFeature.is_active()method.Note
This method will not be called before EVERY
is_activecall, but when using this feature you need to make sure that theDeviceActivityFeature.is_active()call is within theprepare()andcleanupcall.
- is_active() bool
- Returns:
returns True if the device is active, False otherwise
- prepare() None
Prepares the environment to be able to run the
DeviceActivityFeature.is_active()method.Note
This method will not be called before EVERY
is_activecall, but when using this feature you need to make sure that theDeviceActivityFeature.is_active()call is within theprepare()andcleanupcall.
- wait_to_be_active(timeout_sec: float)
This method will wait up to
timeout_secseconds until the device should be shown ACTIVE. If it does not do that within thetimeout_secthe method will raise a TimeoutError.Note
When using this method please make sure that it is embedded within the
prepare()andcleanupcall.- Parameters:
timeout_sec – maximum time to wait for a device to be ACTIVE
- wait_to_be_inactive(timeout_sec: float)
This method will wait up to
timeout_secseconds until the device should be shown INACTIVE. If it does not do that within thetimeout_secthe method will raise a TimeoutError.Note
When using this method please make sure that it is embedded within the
prepare()andcleanupcall.- Parameters:
timeout_sec – maximum time to wait for a device to be INACTIVE
- class balderhub.battery.lib.scenario_features.IsPoweredOn(**kwargs)
Bases:
Featureautonomous feature that describes the state that the device is powered when entering the scenario
- class balderhub.battery.lib.scenario_features.RemovableBatterySimFeature(**kwargs)
Bases:
BatterySimFeatureScenario Level feature implementation of
balderhub.battery.lib.scenario_features.BatterySimFeaturethat can be used for removable batteries.- property battery_inserted: bool
- Returns:
returns True if the battery is inserted at the moment, otherwise False
- fixt_make_sure_device_is_powered_off(restore_entry_state: bool = True) Generator[None, None, None]
This is a fixture that ensures that the device is powered off. It will remove the battery if this is not already done before entering this fixture.
Note
You can directly use this fixture within balder like:
@balder.fixture(...) def my_fixture(...): yield from feat.fixt_make_sure_device_is_powered_off(...)
- Parameters:
restore_entry_state – if Ture, the fixture will restore the state of the battery like it was before entering this fixture within the teardown code
- Returns:
the generator object to use directly as balder fixture
- fixt_make_sure_device_is_powered_on(with_level: float = 1, restart_in_construct: bool = False, restore_entry_state: bool = True) Generator[None, None, None]
This is a fixture that ensures that the device is powered one. It will set the battery to the provided level.
Note
You can directly use this fixture within balder like:
@balder.fixture(...) def my_fixture(...): yield from feat.fixt_make_sure_device_is_powered_on(...)
- Parameters:
with_level – the level the battery should be set to
restart_in_construct – if True, the fixtures will definitely restart the device (power-off and re power on), even if the device was already powered on before entering this fixture
restore_entry_state – if Ture, the fixture will restore the state of the battery like it was before entering this fixture within the teardown code
- Returns:
the generator object to use directly as balder fixture
- insert_battery() None
This callback simulates the inserting of the battery into the device.
- remove_battery()
This callback simulates the removement of the battery into the device.
Setup Features
- class balderhub.battery.lib.setup_features.BatterySimWithProgrammableDcPowerSupply(**kwargs)
Bases:
RemovableBatterySimFeatureSetup Level feature that can be used to simulate the battery behavior with programmable dc power supply instruments.
Note
Please note: This feature is for simple tests, because it does not use the full characteristic and simulates the different values by voltage change only.
- property battery_inserted: bool
- Returns:
returns True if the battery is inserted at the moment, otherwise False
- get_current_active_level() float
This method returns the current setted battery level. :return: the current setted battery level
- get_current_active_voltage() float
- Returns:
returns the current active voltage that is applied at the instrument
- insert_battery()
This callback simulates the inserting of the battery into the device.
- property max_allowed_voltage
- Returns:
security property to limit the maximum allowed voltage the whole feature is allowed to use
- property min_allowed_voltage
- Returns:
security property to limit the minimal allowed voltage the whole feature is allowed to use
- remove_battery()
This callback simulates the removement of the battery into the device.
- set_to(battery_level: float)
This method sets the battery level to the provided value (needs to be between 0 and 1) :param battery_level: :return: