plesty.lib.test.device_param_system
Automated configuration parameter testing utilities for Plesty devices.
Functions
|
Generate a value for one config parameter using metadata-first rules. |
|
Bind mock read/write handlers for config parameter tests. |
|
Assert the mock handlers are the ones answering. |
|
|
|
|
|
Auto test parameter read/write paths for a device class. |
Module Contents
- plesty.lib.test.device_param_system._generate_param_value(param, generator: plesty.lib.sim.data_generator.DataGenerator)
Generate a value for one config parameter using metadata-first rules.
- Parameters:
generator (plesty.lib.sim.data_generator.DataGenerator)
- plesty.lib.test.device_param_system._bind_mock_param_solver(device, generator: plesty.lib.sim.data_generator.DataGenerator)
Bind mock read/write handlers for config parameter tests.
Some real devices require network or hardware access. The mock path keeps auto tests deterministic and side-effect free by storing writes in-memory and generating schema-compatible query responses.
- Parameters:
generator (plesty.lib.sim.data_generator.DataGenerator)
- plesty.lib.test.device_param_system.assert_mock_param_solver_bound(device: Any, when: str) None
Assert the mock handlers are the ones answering.
A device that rebinds
_write_or_query_— during connect, or on the first query, or by falling back to its own internal mock — turns this gate into a test of nothing. plesty-lib#27 is the precedent: a failed connect fell back to a mock solver and three gates reported success having measured nothing.- Parameters:
device (Any) – The device under test.
when (str) – Where in the sweep the check runs; quoted in the failure message.
- Raises:
AssertionError – If either handler no longer points at the mock.
- Return type:
None
- plesty.lib.test.device_param_system._query_test(device, key: str)
- Parameters:
key (str)
- plesty.lib.test.device_param_system._write_test(device, key: str, value: Any)
- Parameters:
key (str)
value (Any)
- plesty.lib.test.device_param_system.auto_test(device_cls: Any, *args: Any, use_mock_solver: bool = True, ignore_keys: Any = None, seed: int | None = 123, sleep_time: float = 0.1, device_kwargs: dict[str, Any] | None = None, **kwargs: Any) None
Auto test parameter read/write paths for a device class.
This test can optionally bind mock config read/write handlers and uses
DataGeneratorto produce values fromConfigParametermetadata.- Parameters:
device_cls (Any) – The device class under test.
*args (Any) – Positional arguments forwarded to
device_cls.use_mock_solver (bool) – Bind the in-memory handlers instead of talking to the device’s own transport.
ignore_keys (Any) – Configuration keys to skip.
seed (int | None) – RNG seed for reproducible generated values.
sleep_time (float) – Delay between keys, to avoid overwhelming an instrument. Ignored under use_mock_solver: there is no instrument to pace, and a fifty-parameter module spent five seconds asleep in CI.
device_kwargs (dict[str, Any] | None) – Keyword arguments forwarded to
device_cls, kept apart from this function’s own. A device constructor taking ause_mock_solverorseedargument — one reference module takes the first — collides with the parameters above when the two are merged, and the call fails with “got multiple values”.**kwargs (Any) – Keyword arguments forwarded to
device_cls. Prefer device_kwargs for anything that might share a name.
- Raises:
AssertionError – If any parameter failed to read or round-trip.
- Return type:
None