plesty.lib.test.device_param_system =================================== .. py:module:: plesty.lib.test.device_param_system .. autoapi-nested-parse:: Automated configuration parameter testing utilities for Plesty devices. Functions --------- .. autoapisummary:: plesty.lib.test.device_param_system._generate_param_value plesty.lib.test.device_param_system._bind_mock_param_solver plesty.lib.test.device_param_system.assert_mock_param_solver_bound plesty.lib.test.device_param_system._query_test plesty.lib.test.device_param_system._write_test plesty.lib.test.device_param_system.auto_test Module Contents --------------- .. py:function:: _generate_param_value(param, generator: plesty.lib.sim.data_generator.DataGenerator) Generate a value for one config parameter using metadata-first rules. .. py:function:: _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. .. py:function:: 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. :param device: The device under test. :param when: Where in the sweep the check runs; quoted in the failure message. :raises AssertionError: If either handler no longer points at the mock. .. py:function:: _query_test(device, key: str) .. py:function:: _write_test(device, key: str, value: Any) .. py:function:: 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 ``DataGenerator`` to produce values from ``ConfigParameter`` metadata. :param device_cls: The device class under test. :param \*args: Positional arguments forwarded to ``device_cls``. :param use_mock_solver: Bind the in-memory handlers instead of talking to the device's own transport. :param ignore_keys: Configuration keys to skip. :param seed: RNG seed for reproducible generated values. :param sleep_time: 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. :param device_kwargs: Keyword arguments forwarded to ``device_cls``, kept apart from this function's own. A device constructor taking a ``use_mock_solver`` or ``seed`` argument — one reference module takes the first — collides with the parameters above when the two are merged, and the call fails with "got multiple values". :param \*\*kwargs: 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.