Browse Source

[1924] Add python group_sent want_reply parameter

So the reporting of errors can be turned on from python.
Michal 'vorner' Vaner 12 years ago
parent
commit
c9ba856c4c
2 changed files with 30 additions and 4 deletions
  1. 3 1
      src/lib/python/isc/cc/session.py
  2. 27 3
      src/lib/python/isc/cc/tests/session_test.py

+ 3 - 1
src/lib/python/isc/cc/session.py

@@ -256,7 +256,8 @@ class Session:
             "instance": instance,
         })
 
-    def group_sendmsg(self, msg, group, instance = "*", to = "*"):
+    def group_sendmsg(self, msg, group, instance = "*", to = "*",
+                      want_answer=False):
         seq = self._next_sequence()
         self.sendmsg({
             "type": "send",
@@ -265,6 +266,7 @@ class Session:
             "group": group,
             "instance": instance,
             "seq": seq,
+            "want_answer": want_answer
         }, isc.cc.message.to_wire(msg))
         return seq
 

+ 27 - 3
src/lib/python/isc/cc/tests/session_test.py

@@ -381,18 +381,42 @@ class testSession(unittest.TestCase):
         sent = sess._socket.readsentmsg_parsed()
         self.assertEqual(sent, ({"from": "test_name", "seq": 2, "to": "*",
                                  "instance": "*", "group": "my_group",
-                                 "type": "send"}, {"hello": "a"}))
+                                 "type": "send", "want_answer": False},
+                                {"hello": "a"}))
         self.assertEqual(sess._sequence, 2)
 
         sess.group_sendmsg({ 'hello': 'a' }, "my_group", "my_instance")
         sent = sess._socket.readsentmsg_parsed()
-        self.assertEqual(sent, ({"from": "test_name", "seq": 3, "to": "*", "instance": "my_instance", "group": "my_group", "type": "send"}, {"hello": "a"}))
+        self.assertEqual(sent, ({"from": "test_name", "seq": 3, "to": "*",
+                                 "instance": "my_instance",
+                                 "group": "my_group", "type": "send",
+                                 "want_answer": False},
+                                {"hello": "a"}))
         self.assertEqual(sess._sequence, 3)
 
         sess.group_sendmsg({ 'hello': 'a' }, "your_group", "your_instance")
         sent = sess._socket.readsentmsg_parsed()
-        self.assertEqual(sent, ({"from": "test_name", "seq": 4, "to": "*", "instance": "your_instance", "group": "your_group", "type": "send"}, {"hello": "a"}))
+        self.assertEqual(sent, ({"from": "test_name", "seq": 4, "to": "*",
+                                 "instance": "your_instance",
+                                 "group": "your_group", "type": "send",
+                                 "want_answer": False},
+                                {"hello": "a"}))
         self.assertEqual(sess._sequence, 4)
+        # Test the optional want_answer parameter
+        sess.group_sendmsg({'hello': 'a'}, "group", want_answer=True)
+        sent = sess._socket.readsentmsg_parsed()
+        self.assertEqual(sent, ({"from": "test_name", "seq": 5, "to": "*",
+                                 "instance": "*", "group": "group", "type":
+                                 "send", "want_answer": True},
+                                {"hello": "a"}))
+        self.assertEqual(sess._sequence, 5)
+        sess.group_sendmsg({'hello': 'a'}, "group", want_answer=False)
+        sent = sess._socket.readsentmsg_parsed()
+        self.assertEqual(sent, ({"from": "test_name", "seq": 6, "to": "*",
+                                 "instance": "*", "group": "group", "type":
+                                 "send", "want_answer": False},
+                                {"hello": "a"}))
+        self.assertEqual(sess._sequence, 6)
 
     def test_group_recvmsg(self):
         # must this one do anything except not return messages with