summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBodo-Merle Sandor <sbodomerle@gmail.com>2018-06-02 14:35:03 +0200
committerBodo-Merle Sandor <sbodomerle@gmail.com>2018-06-02 14:35:03 +0200
commit5bab4440d34980f3722a8e784b6a72804acf5c72 (patch)
tree88360d94c9cc7516d3494f30b2c773d0f9a44a1d /tests
parentc5e62c5a005860459d6ec6b8d104347003e981e9 (diff)
New upstream version 9.2.3
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py5
-rw-r--r--tests/test_async.py77
-rw-r--r--tests/test_client.py2
-rw-r--r--tests/test_server.py4
4 files changed, 83 insertions, 5 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..bf397ef
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,5 @@
+"""Load tango-specific pytest fixtures."""
+
+from tango.test_utils import state, typed_values, server_green_mode
+
+__all__ = ['state', 'typed_values', 'server_green_mode']
diff --git a/tests/test_async.py b/tests/test_async.py
new file mode 100644
index 0000000..9d73e37
--- /dev/null
+++ b/tests/test_async.py
@@ -0,0 +1,77 @@
+
+
+# Imports
+from concurrent.futures import Future
+
+import pytest
+from numpy.testing import assert_array_equal
+
+import tango
+from tango.server import Device, command
+from tango.test_utils import DeviceTestContext
+
+
+def test_async_command_polled(typed_values):
+ dtype, values = typed_values
+
+ if dtype == (bool,):
+ pytest.xfail('Not supported for some reasons')
+
+ class TestDevice(Device):
+
+ @command(dtype_in=dtype, dtype_out=dtype)
+ def identity(self, arg):
+ return arg
+
+ with DeviceTestContext(TestDevice) as proxy:
+ for value in values:
+ eid = proxy.command_inout_asynch('identity', value)
+ result = proxy.command_inout_reply(eid, timeout=500)
+ assert_array_equal(result, value)
+
+
+def test_async_command_with_polled_callback(typed_values):
+ dtype, values = typed_values
+
+ if dtype == (bool,):
+ pytest.xfail('Not supported for some reasons')
+
+ class TestDevice(Device):
+
+ @command(dtype_in=dtype, dtype_out=dtype)
+ def identity(self, arg):
+ return arg
+
+ api_util = tango.ApiUtil.instance()
+ api_util.set_asynch_cb_sub_model(tango.cb_sub_model.PULL_CALLBACK)
+
+ with DeviceTestContext(TestDevice) as proxy:
+ for value in values:
+ future = Future()
+ proxy.command_inout_asynch('identity', value, future.set_result)
+ api_util.get_asynch_replies(500)
+ result = future.result()
+ assert_array_equal(result.argout, value)
+
+
+def test_async_command_with_pushed_callback(typed_values):
+ dtype, values = typed_values
+
+ if dtype == (bool,):
+ pytest.xfail('Not supported for some reasons')
+
+ class TestDevice(Device):
+
+ @command(dtype_in=dtype, dtype_out=dtype)
+ def identity(self, arg):
+ return arg
+
+ api_util = tango.ApiUtil.instance()
+ api_util.set_asynch_cb_sub_model(tango.cb_sub_model.PUSH_CALLBACK)
+
+ with DeviceTestContext(TestDevice) as proxy:
+ for value in values:
+ future = Future()
+ proxy.command_inout_asynch('identity', value, future.set_result)
+ result = future.result(timeout=0.5)
+ assert_array_equal(result.argout, value)
diff --git a/tests/test_client.py b/tests/test_client.py
index 9ab8b55..b988d8e 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -213,7 +213,7 @@ def test_read_attribute(tango_test, readable_attribute):
def test_write_scalar_attribute(tango_test, writable_scalar_attribute):
"Check that writable scalar attributes can be written"
attr_name = writable_scalar_attribute
- config = tango_test.get_attribute_config(writable_scalar_attribute)
+ config = tango_test.get_attribute_config(writable_scalar_attribute, wait=True)
if is_bool_type(config.data_type):
tango_test.write_attribute(attr_name, True, wait=True)
elif is_int_type(config.data_type):
diff --git a/tests/test_server.py b/tests/test_server.py
index 2905e30..42d9605 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -15,10 +15,6 @@ try:
except ImportError:
import trollius as asyncio # noqa: F401
-# Pytest fixtures
-from tango.test_utils import state, typed_values, server_green_mode
-state, typed_values, server_green_mode
-
# Constants
PY3 = sys.version_info >= (3,)
YIELD_FROM = "yield from" if PY3 else "yield asyncio.From"