]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/tests/test_tools.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / tests / test_tools.py
index 0f27ec8e634670b849819589f8c0187f28a880a9..c9cd11bafc8333b457284f8827f00ba23e0aa00f 100644 (file)
@@ -5,17 +5,17 @@ import unittest
 
 import cherrypy
 from cherrypy.lib.sessions import RamSession
+
 try:
     from mock import patch
 except ImportError:
     from unittest.mock import patch
 
-from . import ControllerTestCase
+from .. import DEFAULT_VERSION
+from ..controllers import ApiController, BaseController, Controller, Proxy, RESTController
 from ..services.exception import handle_rados_error
-from ..controllers import RESTController, ApiController, Controller, \
-                          BaseController, Proxy
-from ..tools import dict_contains_path, json_str_to_object, partial_dict,\
-                    dict_get, RequestLoggingTool
+from ..tools import dict_contains_path, dict_get, json_str_to_object, partial_dict
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 # pylint: disable=W0613
@@ -70,9 +70,8 @@ class FooArgs(RESTController):
         raise cherrypy.NotFound()
 
 
-# pylint: disable=blacklisted-name
 class Root(object):
-    foo = FooResource()
+    foo_resource = FooResource()
     fooargs = FooArgs()
 
 
@@ -88,7 +87,8 @@ class RESTControllerTest(ControllerTestCase):
         self.assertStatus(204)
         self._get("/foo")
         self.assertStatus('200 OK')
-        self.assertHeader('Content-Type', 'application/json')
+        self.assertHeader('Content-Type',
+                          'application/vnd.ceph.api.v{}+json'.format(DEFAULT_VERSION))
         self.assertBody('[]')
 
     def test_fill(self):
@@ -99,16 +99,19 @@ class RESTControllerTest(ControllerTestCase):
                 self._post("/foo", data)
                 self.assertJsonBody(data)
                 self.assertStatus(201)
-                self.assertHeader('Content-Type', 'application/json')
+                self.assertHeader('Content-Type',
+                                  'application/vnd.ceph.api.v{}+json'.format(DEFAULT_VERSION))
 
             self._get("/foo")
             self.assertStatus('200 OK')
-            self.assertHeader('Content-Type', 'application/json')
+            self.assertHeader('Content-Type',
+                              'application/vnd.ceph.api.v{}+json'.format(DEFAULT_VERSION))
             self.assertJsonBody([data] * 5)
 
             self._put('/foo/0', {'newdata': 'newdata'})
             self.assertStatus('200 OK')
-            self.assertHeader('Content-Type', 'application/json')
+            self.assertHeader('Content-Type',
+                              'application/vnd.ceph.api.v{}+json'.format(DEFAULT_VERSION))
             self.assertJsonBody({'newdata': 'newdata', 'key': '0'})
 
     def test_not_implemented(self):
@@ -151,10 +154,7 @@ class RESTControllerTest(ControllerTestCase):
 
 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):