Mock device

This module implements infrastructure for mocking tango devices.

class MockDeviceBuilder(from_factory=<class 'unittest.mock.Mock'>)

This module implements a mock builder for tango devices.

__init__(from_factory=<class 'unittest.mock.Mock'>)

Create a new instance.

Parameters:

from_factory (type[Mock]) – an optional factory from which to draw the original mock

add_attribute(name, value)

Tell this builder to build mocks with a given attribute.

TODO: distinguish between read-only and read-write attributes

Parameters:
  • name (str) – name of the attribute

  • value (Any) – the value of the attribute

Return type:

None

add_command(name, return_value)

Tell this builder to build mocks with a specified command.

And that the command returns the provided value.

Parameters:
  • name (str) – name of the command

  • return_value (Any) – what the command should return

Return type:

None

add_result_command(name, result_code, status='Mock information-only message')

Tell this builder to build mocks with a specified command.

And that the command returns (ResultCode, [message, message_uid]) or (ResultCode, message) tuples as required.

Parameters:
  • name (str) – the name of the command

  • result_code (ResultCode) – code indicating the status of the command

  • status (str) – an information-only message for the command to return

Return type:

None

set_state(state)

Tell this builder to build mocks with the state set as specified.

Parameters:

state (DevState) – the state of the mock

Return type:

None