Details
-
Enabler
-
None
-
Obs Mgt & Controls
-
-
-
2
-
2
-
3
-
Team_KAROO
-
Sprint 5
-
-
-
5.6
-
-
Enabler Team_KAROO goal_O3 testing
Description
Investigate mocking/patching to allow a PyTango device to be instantiated without actually running it in a subprocess with the TANGO runtime components. In this case the basic behaviour of all methods could be unit tested. It would require mocking/patching the PyTango Device class, or at least SKABaseDevice, so that it does not try to call the bootstrapped libtango DeviceImpl constructors. It should still call the device under test’s init_device method but not try to connect to a TANGO database. Obviously, if the device instantiates DeviceProxy objects to connect to dependent devices, it would useful to mock those devices’ basic behaviour too (commands and attributes). There would still need to be integration level testing that actually runs the real devices, but the unit testing could be simplified.
The above is suggested in Testing TANGO Controls - see the details and conceptual example in the "Future Work / Potential Solutions" section.
Acceptance Criteria
there are examples of tango devices whose proxies are mocked with pytest mock/patch, and the mocks are used to support unit testing of methods implementing commands, attributes, states of the device.some mocks are designed so to support testing of methods that are called according to an event-driven approach (eg on attribute changes).no interaction between tango devices is handled nor assumed by these tests.no interaction with Tango database is handled either.