Commit 6ff2a83c authored by Naoki Kambe's avatar Naoki Kambe

[trac521] added a test case "test_command_handler" for bob.command_handler,

which tests for bad commamd, "shutdown", "sendstats" and an unknown command, and tests values of parameters transmitted through the cc session.
parent 682ea37c
from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file
from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file, _BASETIME
# XXX: environment tests are currently disabled, due to the preprocessor
# setup that we have now complicating the environment
......@@ -9,6 +9,8 @@ import os
import signal
import socket
from import IPAddr
import time
import isc
class TestProcessInfo(unittest.TestCase):
def setUp(self):
......@@ -104,6 +106,29 @@ class TestBoB(unittest.TestCase):
self.assertEqual(bob.cfg_start_auth, True)
self.assertEqual(bob.cfg_start_resolver, False)
def test_command_handler(self):
class DummySession():
def group_sendmsg(self, msg, group):
(self.msg, = (msg, group)
def group_recvmsg(self, nonblock, seq): pass
bob = BoB()
bob.cc_session = DummySession()
self.assertEqual(bob.command_handler(-1, None),
isc.config.ccsession.create_answer(1, "bad command"))
self.assertEqual(bob.command_handler("shutdown", None),
self.assertEqual(bob.command_handler("sendstats", None),
self.assertEqual(, "Stats")
'set', { "stats_data": {
'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
self.assertEqual(bob.command_handler("__UNKNOWN__", None),
isc.config.ccsession.create_answer(1, "Unknown command"))
# Class for testing the BoB start/stop components routines.
# Although testing that external processes start is outside the scope
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment