Browse Source

[2823] updated init_hterr test for stats httpd using the new mock class

JINMEI Tatuya 12 years ago
parent
commit
db5ddcf7b6

+ 1 - 7
src/bin/stats/tests/b10-stats-httpd_test.py

@@ -637,17 +637,11 @@ class TestStatsHttpd(unittest.TestCase):
         self.assertEqual('StatsHttpd', self.stats_httpd.mccs.\
         self.assertEqual('StatsHttpd', self.stats_httpd.mccs.\
                              get_module_spec().get_module_name())
                              get_module_spec().get_module_name())
 
 
-    @unittest.skipIf(True, 'tentatively skipped')
     def test_init_hterr(self):
     def test_init_hterr(self):
         orig_open_httpd = stats_httpd.StatsHttpd.open_httpd
         orig_open_httpd = stats_httpd.StatsHttpd.open_httpd
         def err_open_httpd(arg): raise stats_httpd.HttpServerError
         def err_open_httpd(arg): raise stats_httpd.HttpServerError
         stats_httpd.StatsHttpd.open_httpd = err_open_httpd
         stats_httpd.StatsHttpd.open_httpd = err_open_httpd
-        self.assertRaises(stats_httpd.HttpServerError, stats_httpd.StatsHttpd)
-        ans = send_command(
-            isc.config.ccsession.COMMAND_GET_MODULE_SPEC,
-            "ConfigManager", {"module_name":"StatsHttpd"})
-        # assert StatsHttpd is removed from ConfigManager
-        self.assertEqual(ans, (0,{}))
+        self.assertRaises(stats_httpd.HttpServerError, SimpleStatsHttpd)
         stats_httpd.StatsHttpd.open_httpd = orig_open_httpd
         stats_httpd.StatsHttpd.open_httpd = orig_open_httpd
 
 
     @unittest.skipIf(True, 'tentatively skipped')
     @unittest.skipIf(True, 'tentatively skipped')

+ 4 - 2
src/bin/stats/tests/test_utils.py

@@ -602,6 +602,7 @@ class SimpleStatsHttpd(stats_httpd.StatsHttpd):
     ORIG_SPECFILE_LOCATION = stats_httpd.SPECFILE_LOCATION
     ORIG_SPECFILE_LOCATION = stats_httpd.SPECFILE_LOCATION
     def __init__(self, *server_address):
     def __init__(self, *server_address):
         self._started = threading.Event()
         self._started = threading.Event()
+        self.__dummy_socks = None # see below
 
 
         # Prepare commonly used statistics schema and data requested in
         # Prepare commonly used statistics schema and data requested in
         # stats-httpd tests.  For the purpose of these tests, the content of
         # stats-httpd tests.  For the purpose of these tests, the content of
@@ -667,8 +668,9 @@ class SimpleStatsHttpd(stats_httpd.StatsHttpd):
         self.mccs.start = self.load_config # force reload
         self.mccs.start = self.load_config # force reload
 
 
     def close_mccs(self):
     def close_mccs(self):
-        self.__dummy_socks[0].close()
-        self.__dummy_socks[1].close()
+        if self.__dummy_socks is not None:
+            self.__dummy_socks[0].close()
+            self.__dummy_socks[1].close()
 
 
     def __rpc_call(self, command, group, params={}):
     def __rpc_call(self, command, group, params={}):
         """Faked ModuleCCSession.rpc_call for tests.
         """Faked ModuleCCSession.rpc_call for tests.