def setUp(self):
    ' Patches handlers of Taskqueue application in order\n    to prevent real calls to Cassandra and Datastore because only\n    service statistics matters for this test.\n    '
    super(TestServiceStatistics, self).setUp()
    handlers = [rest_api.RESTQueue, rest_api.RESTTask, rest_api.RESTLease, rest_api.RESTTasks]
    self.patchers = []
    self.get_http_status_mock = mock.MagicMock()
    for handler in handlers:
        patcher = patch.object(handler, 'get_status', self.get_http_status_mock)
        patcher.start()
        self.patchers.append(patcher)
        for method in ['get', 'post', 'put', 'delete', 'patch']:

            def method_impl(*args, **kwargs):
                return None
            patcher = patch.object(handler, method, method_impl)
            patcher.start()
            self.patchers.append(patcher)
    remote_request_patcher = patch.object(appscale_taskqueue.ProtobufferHandler, 'remote_request')
    self.pb_remote_request_mock = remote_request_patcher.start()
    self.patchers.append(remote_request_patcher)
    time_patcher = patch.object(stats_manager.time, 'time')
    self.time_mock = time_patcher.start()
    self.patchers.append(time_patcher)
Patches handlers of Taskqueue application in order
to prevent real calls to Cassandra and Datastore because only
service statistics matters for this test.
def setUp(self):
    ' Patches handlers of Taskqueue application in order\n    to prevent real calls to Cassandra and Datastore because only\n    service statistics matters for this test.\n    '
    super(TestServiceStatistics, self).setUp()
    handlers = [rest_api.RESTQueue, rest_api.RESTTask, rest_api.RESTLease, rest_api.RESTTasks]
    self.patchers = []
    self.get_http_status_mock = mock.MagicMock()
    for handler in handlers:
        patcher = patch.object(handler, 'get_status', self.get_http_status_mock)
        patcher.start()
        self.patchers.append(patcher)
        for method in ['get', 'post', 'put', 'delete', 'patch']:

            def method_impl(*args, **kwargs):
                return None
            patcher = patch.object(handler, method, method_impl)
            patcher.start()
            self.patchers.append(patcher)
    remote_request_patcher = patch.object(appscale_taskqueue.ProtobufferHandler, 'remote_request')
    self.pb_remote_request_mock = remote_request_patcher.start()
    self.patchers.append(remote_request_patcher)
    time_patcher = patch.object(stats_manager.time, 'time')
    self.time_mock = time_patcher.start()
    self.patchers.append(time_patcher)