

@defer.inlineCallbacks
def test_out_of_service(self):
    called = []

    def cb(r):
        called.append(r)
    request = {
        'jsonrpc': '2.0',
        'method': 'delay',
        'params': [1],
        'id': '1',
    }
    d = self.service.call(json.dumps(request))
    d = self.service.stopServing(FooException)
    d.addBoth(cb)
    request = {
        'jsonrpc': '2.0',
        'method': 'error',
        'id': '1',
    }
    expected = {
        'jsonrpc': '2.0',
        'error': {
            'code': (- 32099),
            'message': 'Foo',
        },
        'id': '1',
    }
    (yield self.makeRequest(request, expected))
    clock.advance(2)
    (yield d)
    self.assertEqual(len(called), 1)

dataset/ETHPy150Open flowroute/txjason/txjason/tests/test_service.py ServiceTestCase.test_out_of_service/original