

def test_handle(self):
    inst = instance.Instance(self.request_data, 'name', self.proxy, max_concurrent_requests=5)
    self.mox.StubOutWithMock(inst._condition, 'notify')
    self.proxy.start()
    self.environ = {
        
    }
    self.request_data.set_request_instance(self.request_id, inst)
    self.proxy.handle(self.environ, self.start_response, self.url_map, self.match, self.request_id, instance.NORMAL_REQUEST).AndReturn(self.response)
    inst._condition.notify()
    self.mox.ReplayAll()
    now = time.time()
    inst._request_history.append(((now - 100), (now - 80)))
    inst.start()
    self.assertTrue(inst.can_accept_requests)
    self.assertEqual(self.response, list(inst.handle(self.environ, self.start_response, self.url_map, self.match, self.request_id, instance.NORMAL_REQUEST)))
    self.mox.VerifyAll()
    self.assertEqual(1, len(inst._request_history))
    self.assertEqual(1, inst.total_requests)
    self.assertEqual(5, inst.remaining_request_capacity)
    self.assertEqual(0, inst.num_outstanding_requests)
    self.assertTrue((0 < inst.get_qps_60s()))

dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/instance_test.py TestInstance.test_handle/original