Mocking calls to tang group apis

Hi,
I am working on a project where there are multiple tango devices working in hierarchy(one DS per device). There is one higher level device that also act as tango client of multiple lower level devices. This higher level device creates a tango group consisting multiple devices and invokes commands on them. Additionally, there are few more devices which are not included in the group and the high level device invokes command on them using DeviceProxy
There are some unit test cases written on the higher level device. The test cases use DeviceTestContext to setup a tango system (that has higher level device registered)for unit testing. We can mock the device proxies and by writing a side effect function, we can generate desired response from the devices which are not part of the group. But we are not able to mock the calls to tango group apis. We tried to patch the constructor but its not working. We get exception as follows:

1604328467 [140400341755712] ERROR test/nodb/subarraynode 1|2020-11-02T14:47:47.400Z|ERROR|MainThread|do|abort_command.py#55|tango-device:test/nodb/subarraynode|DevFailed[DevError[
desc = TANGO_HOST env. variable not set, set it and retry (e.g. TANGO_HOST=<host>:<port>)
origin = Database::Database
reason = API_TangoHostNotSet
severity = ERR]
]
Traceback (most recent call last):
File "/builds/ska-telescope/tmc-prototype/tmcprototype/subarraynode/.tox/py37/lib/python3.7/site-packages/subarraynode/abort_command.py", line 46, in do
device._dish_leaf_node_group.command_inout(const.CMD_ABORT)
File "/builds/ska-telescope/tmc-prototype/tmcprototype/subarraynode/.tox/py37/lib/python3.7/site-packages/tango/group.py", line 127, in command_inout
idx = self.command_inout_asynch(cmd_name, forget=False, forward=forward)
File "/builds/ska-telescope/tmc-prototype/tmcprototype/subarraynode/.tox/py37/lib/python3.7/site-packages/tango/group.py", line 174, in fn
return getattr(self._Group__group, fname)(*args, **kwds)
PyTango.ConnectionFailed: DevFailed[
DevError[
desc = TANGO_HOST env. variable not set, set it and retry (e.g. TANGO_HOST=<host>:<port>)
origin = Database::Database
reason = API_TangoHostNotSet
severity = ERR]
]
1|2020-11-02T14:47:47.400Z|ERROR|MainThread|do|abort_command.py#55|tango-device:test/nodb/subarraynode|DevFailed[
DevError[
desc = TANGO_HOST env. variable not set, set it and retry (e.g. TANGO_HOST=<host>:<port>)
origin = Database::Database
reason = API_TangoHostNotSet
severity = ERR]
]


Can anybody provide inputs on this?
Hi Aditya

I suspect that mock patching of the tango.Group constructor is not being done correctly. It should be similar to the way the DeviceProxy is patched. In both cases you are trying to completely bypass the Tango functionality. If we see the undefined TANGO_HOST error then the tango.Group object definitely hasn't been patched successfully.

We can look at the code you have via the SKA communications channels.

Regards,

Anton
 
Register or login to create to post a reply.