Browse Source

[2922] Make sure the result is JSON encodable

Michal 'vorner' Vaner 12 years ago
parent
commit
40e0617397
2 changed files with 6 additions and 1 deletions
  1. 2 1
      src/bin/msgq/msgq.py.in
  2. 4 0
      src/bin/msgq/tests/msgq_test.py

+ 2 - 1
src/bin/msgq/msgq.py.in

@@ -819,7 +819,8 @@ class MsgQ:
                         list(map(lambda sock: self.fd_to_lname[sock.fileno()],
                                  self.subs.find(group, ''))))
                 else:
-                    return isc.config.create_answer(0, self.lnames.keys())
+                    return isc.config.create_answer(0,
+                                                    list(self.lnames.keys()))
 
             config_logger.error(MSGQ_COMMAND_UNKNOWN, command)
             return isc.config.create_answer(1, 'unknown command: ' + command)

+ 4 - 0
src/bin/msgq/tests/msgq_test.py

@@ -220,6 +220,10 @@ class MsgQTest(unittest.TestCase):
             array = result['result'][1]
             self.assertEqual(set(['first', 'second']), set(array))
             self.assertEqual({'result': [0, array]}, result)
+            # Make sure the result can be encoded as JSON
+            # (there seems to be types that look like a list but JSON choks
+            # on them)
+            json.dumps(result)
         # Members of the G1 and G2
         self.assertEqual({'result': [0, ["second"]]},
                          self.__msgq.command_handler('members',