[pytango] 52/122: Add test_identity_command

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:18:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to tag v9.2.1
in repository pytango.

commit d1d6d629a01dd9eb9dc542d67a6e1fd57a589e05
Author: Vincent Michel <vincent.michel at maxlab.lu.se>
Date:   Mon Oct 10 17:02:01 2016 +0200

    Add test_identity_command
---
 test/test_server.py | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/test/test_server.py b/test/test_server.py
index 488fb2d..d697d80 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -3,17 +3,40 @@
 import pytest
 from six import add_metaclass
 
-from tango import DevState
-from tango.server import Device, DeviceMeta
+import tango
+from tango import DevState, utils
+from tango.server import Device, DeviceMeta, command
 
 from context import TangoTestContext
 
 
+# Fixtures
+
 @pytest.fixture(params=DevState.names.values())
 def state(request):
     return request.param
 
 
+ at pytest.fixture(params=utils._scalar_types)
+def type_value(request):
+    dtype = request.param
+    # Unsupported types
+    if dtype in [tango.DevInt, tango.ConstDevString,
+                 tango.DevEncoded, tango.DevUChar]:
+        pytest.xfail('Should we support those types?')
+    # Supported types
+    if dtype in utils._scalar_str_types:
+        return dtype, ['hey hey', 'my my']
+    if dtype in utils._scalar_bool_types:
+        return dtype, [False, True]
+    if dtype in utils._scalar_int_types:
+        return dtype, [1, 2]
+    if dtype in utils._scalar_float_types:
+        return dtype, [2.71, 3.14]
+
+
+# Test state/status
+
 def test_empty_device():
 
     @add_metaclass(DeviceMeta)
@@ -54,3 +77,21 @@ def test_set_status():
     with TangoTestContext(TestDevice) as proxy:
         assert proxy.state() == DevState.ON
         assert proxy.status() == status
+
+
+# Test commands
+
+def test_identity_command(type_value):
+    dtype, values = type_value
+
+    @add_metaclass(DeviceMeta)
+    class TestDevice(Device):
+
+        @command(dtype_in=dtype, dtype_out=dtype)
+        def identity(self, arg):
+            return arg
+
+    with TangoTestContext(TestDevice) as proxy:
+        for value in values:
+            expected = pytest.approx(value)
+            assert proxy.identity(value) == expected

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list