Hi Everyone,
I am writing test cases for TANGO devices using Pytest. I have a few queries about the same.
1. Test TANGO clients
I have two TANGO devices, device A (a client) and device B(a server). Command invoked from device A, internally invokes command of device B and as a result some of the attributes of TANGO device B change.
Testing approach:
To test the command of device A, I create a proxy of device B (from test function of device A) and assert with changed attributes of device B. For the test to pass successfully, there is a dependency on Device B to be up and running.
Issue: Since the communication between Device A and Device B may take some time, I get Segmentation fault error. One possibility can be that the assert statement is checked while device B takes time to respond to the change. The error is resolved when the test is run again. I have also tried to add time.sleep(3) statement but still no luck.
I need help on how to overcome the Segmentation Fault issue. Also, how shall I test Device A without depending on Device B?
2. Access device properties inside test_context.py
The Tango Device A uses a device property during it’s initialization. Hence, there is a need to supply this device property in order to test Device A.
Issue:
It is observed that init function in test_context.py takes properties as input. However, while trying below solution, properties for the instance (tango_context) of device is not set. Hence, the device A’s initialization is getting failed which result in all the test cases to fail unless we define a default value for each property.
File: conftest.py
# some imports
from tango.test_context import DeviceTestContext
@pytest.fixture(scope="class")
def tango_context(request):
# code to get klass name
properties = {'DeviceB_FQDN': 'tango://test/device/b'}
tango_context = DeviceTestContext(klass, properties=properties)
tango_context.start()
3. Defining attribute properties for Forwarded Attributes
Some attributes of Device B are forwarded on Device A. However, it is mandatory to specify __root_attr attribute property to initialze device A successfully. Without this property, device A goes into Alarm state after initialization.
Is there any way to add attribute property and return test_context of Device A? Also, how to set default value for __root_attr in python?
4. Testing events
Comment on test_client.py says that:
"""Client tests that run against the standard TangoTest device.
Due to a TANGO 9 issue (#821), the device is run without any database.
Note that this means that various features won't work:
* No device configuration via properties.
* No event generated by the server.
* No memorized attributes.
* No device attribute configuration via the database.
So don't even try to test anything of the above as it will not work
and is even likely to crash the device (!)
"""
Is there any workaround to enable testing of events and device/attribute configuration through properties?
I understand that it is a long post but any inputs on above queries will be helpful. ![]()
Christmas wishes,
Apurva Patkar