Example #1
0
    def test_ping_property(self):
        response = EventSourceResponse()
        default = response.DEFAULT_PING_INTERVAL
        self.assertEqual(response.ping_interval, default)
        response.ping_interval = 25
        self.assertEqual(response.ping_interval, 25)
        with self.assertRaisesRegex(TypeError, 'ping interval'):
            response.ping_interval = 'ten'

        with self.assertRaises(ValueError):
            response.ping_interval = -42
Example #2
0
def test_ping_property(loop):
    response = EventSourceResponse()
    default = response.DEFAULT_PING_INTERVAL
    assert response.ping_interval == default
    response.ping_interval = 25
    assert response.ping_interval == 25
    with pytest.raises(TypeError) as ctx:
        response.ping_interval = 'ten'

    assert str(ctx.value) == 'ping interval must be int'

    with pytest.raises(ValueError):
        response.ping_interval = -42
Example #3
0
 async def func(request):
     app = request.app
     resp = EventSourceResponse()
     resp.ping_interval = 1
     await resp.prepare(request)
     resp.send('foo')
     app['socket'].append(resp)
     await resp.wait()
     return resp
Example #4
0
 def func(request):
     app = request.app
     resp = EventSourceResponse()
     resp.ping_interval = 1
     resp.start(request)
     resp.send('foo')
     app['socket'].append(resp)
     yield from resp.wait()
     return resp