from ..plugins import PLUGIN_MANAGER, debug, feature_toggles # noqa
from ..services.auth import AuthManagerTool
from ..services.exception import dashboard_exception_handler
+from ..tools import RequestLoggingTool
PLUGIN_MANAGER.hook.init()
PLUGIN_MANAGER.hook.register_commands()
cherrypy.tree.mount(None, config={
base_url: {'request.dispatch': mapper}})
- def __init__(self, *args, **kwargs):
+ _request_logging = False
+
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
cherrypy.tools.authenticate = AuthManagerTool()
cherrypy.tools.dashboard_exception_handler = HandlerWrapperTool(dashboard_exception_handler,
priority=31)
'tools.json_in.force': False
})
PLUGIN_MANAGER.hook.configure_cherrypy(config=cherrypy.config)
- super(ControllerTestCase, self).__init__(*args, **kwargs)
+
+ if cls._request_logging:
+ cherrypy.tools.request_logging = RequestLoggingTool()
+ cherrypy.config.update({'tools.request_logging.on': True})
+
+ @classmethod
+ def tearDownClass(cls):
+ if cls._request_logging:
+ cherrypy.config.update({'tools.request_logging.on': False})
def _request(self, url, method, data=None, headers=None):
if not data:
import json
import re
-import cherrypy
-
try:
import mock
except ImportError:
from .. import mgr
from ..controllers import Controller, RESTController
-from ..tools import RequestLoggingTool
from . import ControllerTestCase, KVStoreMockMixin # pylint: disable=no-name-in-module
class ApiAuditingTest(ControllerTestCase, KVStoreMockMixin):
- def __init__(self, *args, **kwargs):
- cherrypy.tools.request_logging = RequestLoggingTool()
- cherrypy.config.update({'tools.request_logging.on': True})
- super(ApiAuditingTest, self).__init__(*args, **kwargs)
+ _request_logging = True
@classmethod
def setup_server(cls):
SettingsController._cp_config['tools.authenticate.on'] = False
cls.setup_controllers([SettingsController])
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ # pylint: disable=protected-access
+ settings.Options.GRAFANA_API_HOST = ('localhost', str)
+ settings.Options.GRAFANA_ENABLED = (False, bool)
+
+ @classmethod
+ def tearDownClass(cls):
+ super().tearDownClass()
+
def setUp(self):
+ super().setUp()
self.mock_kv_store()
def test_settings_list(self):
from ..controllers import ApiController, BaseController, Controller, Proxy, RESTController
from ..services.exception import handle_rados_error
-from ..tools import RequestLoggingTool, dict_contains_path, dict_get, \
- json_str_to_object, partial_dict
+from ..tools import dict_contains_path, dict_get, json_str_to_object, partial_dict
from . import ControllerTestCase # pylint: disable=no-name-in-module
class RequestLoggingToolTest(ControllerTestCase):
- def __init__(self, *args, **kwargs):
- cherrypy.tools.request_logging = RequestLoggingTool()
- cherrypy.config.update({'tools.request_logging.on': True})
- super(RequestLoggingToolTest, self).__init__(*args, **kwargs)
+ _request_logging = True
@classmethod
def setup_server(cls):