Scenarios

Scenarios describe what you need. They define the tests and the necessary devices for them. Here you can find all scenarios that are implemented in this BalderHub package.

Battery Service

class balderhub.ble.scenarios.ScenarioBatteryService

Bases: Scenario

Test scenario that validates the device information service

class Controller

Bases: Device

device receiving the heart rate data

class DeviceUnderTest

Bases: Device

device detecting the row heart rate

make_sure_that_we_are_connected()

fixture that ensures that controller is connected

test_read_battery_level_once() None

Simple test that reads the battery level once and validates that it is between 0 and 100

Device Information Service

class balderhub.ble.scenarios.ScenarioDeviceInformationService

Bases: Scenario

Test scenario that validates the device information service

class Controller

Bases: Device

device receiving the heart rate data

class DeviceUnderTest

Bases: Device

device detecting the row heart rate

make_sure_that_we_are_connected()

fixture that ensures that controller is connected

test_pnp_id()

Special test for the PNP-ID object.

It validates if it response with the correct values. In case the characteristic is marked as non-active (see property balderhub.ble.lib.scenario_features.DeviceInformationConfig.pnp_id()), it will check that it raises an exception that the characteristic was not found.

test_value(config_and_char: tuple[str, type[balderhub.ble.lib.utils.characteristic.Characteristic]])

This test will be executed for every existing characteristic in the Device-Information Service and validates if it response with the correct values. In case the characteristic is marked as non-active (see properties in balderhub.ble.lib.scenario_features.DeviceInformationConfig), it will check that it raises an exception that the characteristic was not found.

Parameters:

config_and_char – parametrized configuration with the property name as first element and the characteristic as second

Heart-Rate Profile / Service

class balderhub.ble.scenarios.ScenarioHrProfileAdvertisements

Bases: Scenario

Test scenario that validates if heart-rate sensor with active hr-profile sends Advertisements correctly

class Heart

Bases: Device

device simulating the heart beat

class HeartRateHost

Bases: Device

device receiving the heart rate data

class HeartRateSensor

Bases: Device

device detecting the row heart rate

make_sure_to_stop_advertising(start_observer)

fixture that ensures that no advertisements are sent (and the device is really shut down) before entering the test

start_observer()

starts the advertisement observer

test_is_advertising_as_soon_as_strap_attached(with_heart_beat)

This test makes sure that the DUT is advertising as soon as the strap is attached :param with_heart_beat: test will be executed once with heart beat and another time without active heart beat

test_is_advertising_when_pulse_is_gone(strap_remains_attached)

This test validates if the DUT is still advertising when the pulse is gone. :param strap_remains_attached: test will be executed once with strap attached and once without attached strap

class balderhub.ble.scenarios.ScenarioHeartRateService

Bases: Scenario

Test scenario that validates a heart rate sensor according the definitions made from HeartRateService

class Heart

Bases: Device

device simulating the heart beat

class HeartRateHost

Bases: Device

device receiving the heart rate data

class HeartRateSensor

Bases: Device

device detecting the row heart rate

property active_characteristic
Returns:

helper property for getting the Measurement characteristic

make_sure_that_we_are_connected()

fixture that ensures that controller is connected

start_notification()
Returns:

register the notification for the measurement characteristic

test_sensorcontact_bit()

test that validates that the sensor contact support and status bit are handled correctly

test_validate_heart_rate()

Simple test that validates the heart beats sent by the sensor