[pytango] 47/122: Add 3 unit-tests for the server API

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 5d2713920225dd8aee26aa073a74839c83b9ed8b
Author: Vincent Michel <vincent.michel at maxlab.lu.se>
Date:   Fri Sep 30 17:29:06 2016 +0200

    Add 3 unit-tests for the server API
---
 test/test_server.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/test/test_server.py b/test/test_server.py
new file mode 100644
index 0000000..e070e45
--- /dev/null
+++ b/test/test_server.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+from tango import DevState
+from tango.server import Device, DeviceMeta
+
+from context import TangoTestContext
+
+
+def test_empty_device():
+
+    class TestDevice(Device):
+        __metaclass__ = DeviceMeta
+
+    with TangoTestContext(TestDevice) as proxy:
+        assert proxy.state() == DevState.UNKNOWN
+        assert proxy.status() == 'The device is in UNKNOWN state.'
+
+
+def test_set_state():
+
+    class TestDevice(Device):
+        __metaclass__ = DeviceMeta
+
+        def init_device(self):
+            print('hey')
+            self.set_state(DevState.ON)
+
+    with TangoTestContext(TestDevice) as proxy:
+        assert proxy.state() == DevState.ON
+        assert proxy.status() == 'The device is in ON state.'
+
+
+def test_set_status():
+
+    status = '\n'.join((
+        "This is a multiline status",
+        "with special characters such as",
+        "Café à la crème"))
+
+    class TestDevice(Device):
+        __metaclass__ = DeviceMeta
+
+        def init_device(self):
+            self.set_state(DevState.ON)
+            self.set_status(status)
+
+    with TangoTestContext(TestDevice) as proxy:
+        assert proxy.state() == DevState.ON
+        assert proxy.status() == status

-- 
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