Browse Source

[trac547] removed assertions checking type or instance because of reusability of module

Naoki Kambe 14 years ago
parent
commit
41361697fe

+ 0 - 11
src/bin/stats/stats_httpd.py.in

@@ -71,7 +71,6 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
         self.send_head()
 
     def send_head(self):
-        assert isinstance(self.server, HttpServer)
         try:
             if self.path == XML_URL_PATH:
                 body = self.server.xml_handler()
@@ -107,7 +106,6 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
 
     def log_message(self, format, *args):
         """Change the default log format"""
-        assert isinstance(self.server, HttpServer)
         if self.server.verbose:
             self.server.log_writer(
                 "[b10-stats-httpd] %s - - [%s] %s\n" %
@@ -198,8 +196,6 @@ class StatsHttpd:
         from the config manager"""
         # load config
         if len(new_config) > 0:
-            assert type(self.config) is dict
-            assert type(new_config) is dict
             self.config.update(new_config)
         else:
             self.config = DEFAULT_CONFIG
@@ -209,8 +205,6 @@ class StatsHttpd:
                         for itm in self.mccs.get_module_spec().get_config_spec()
                         ])
                 )
-        assert 'listen_on' in self.config
-        assert type(self.config['listen_on']) is list
         # remove duplicated element
         self.http_addrs = list(
             set([ (cf['address'], cf['port']) for cf in self.config['listen_on'] ])
@@ -219,12 +213,10 @@ class StatsHttpd:
     def open_httpd(self):
         """Opens sockets for HTTP. Iterating each HTTP address to be
         configured in spec file"""
-        assert type(self.http_addrs) is list
         for addr in self.http_addrs:
             self.httpd.append(self._open_httpd(addr))
 
     def _open_httpd(self, server_address, address_family=None):
-        assert type(server_address) is tuple
         try:
             # try IPv6 at first
             if address_family is not None:
@@ -250,7 +242,6 @@ class StatsHttpd:
                 self.write_log(
                     "[b10-stats-httpd] Started on address %s, port %s\n" %
                     server_address)
-        assert isinstance(httpd, HttpServer)
         return httpd
 
     def close_httpd(self):
@@ -258,7 +249,6 @@ class StatsHttpd:
         if len(self.httpd) == 0:
             return
         for ht in self.httpd:
-            assert type(ht.server_address) is tuple
             if self.verbose:
                 self.write_log(
                     "[b10-stats-httpd] Closing address %s, port %s\n" %
@@ -312,7 +302,6 @@ class StatsHttpd:
     def config_handler(self, new_config):
         """Config handler for the ModuleCCSession object. It resets
         addresses and ports to listen HTTP requests on."""
-        assert type(new_config) is dict
         if self.verbose:
             self.write_log("[b10-stats-httpd] Loading config : %s\n" % str(new_config))
         for key in new_config.keys():

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

@@ -362,7 +362,6 @@ class TestStatsHttpd(unittest.TestCase):
 
     def test_config(self):
         d = dict(_UNKNOWN_KEY_=None)
-        assert type(d) is dict
         self.assertEqual(
             self.stats_httpd.config_handler(d),
             isc.config.ccsession.create_answer(

+ 0 - 2
src/bin/stats/tests/http/server.py

@@ -22,7 +22,6 @@ class DummyHttpResponse:
         self.log = ""
 
     def _write_log(self, msg):
-        assert type(msg) is str
         self.log = self.log + msg
 
 class HTTPServer:
@@ -85,6 +84,5 @@ class BaseHTTPRequestHandler:
     def _write(self, obj):
         if self.path != self.response.path:
             self.response = DummyHttpResponse(path=self.path)
-        assert type(obj) is bytes
         self.response.body = obj.decode()
 

+ 0 - 2
src/bin/stats/tests/isc/config/ccsession.py

@@ -22,7 +22,6 @@ from isc.cc.session import Session
 COMMAND_CONFIG_UPDATE = "config_update"
 
 def parse_answer(msg):
-    assert type(msg) is dict
     assert 'result' in msg
     try:
         return msg['result'][0], msg['result'][1]
@@ -36,7 +35,6 @@ def create_answer(rcode, arg = None):
         return { 'result': [ rcode, arg ] }
 
 def parse_command(msg):
-    assert type(msg) is dict
     assert 'command' in msg
     try:
         return msg['command'][0], msg['command'][1]