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
raise cherrypy.NotFound()
-# pylint: disable=blacklisted-name
class Root(object):
- foo = FooResource()
+ foo_resource = FooResource()
fooargs = FooArgs()
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):
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):
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):