def when_both_sides_close_channel(self): # Client tries to close connection self.task = asyncio.async(self.connection.close(), loop=self.loop) self.tick() # Before OK arrives server closes connection self.server.send_method( 0, spec.ConnectionClose(123, 'you muffed up', 10, 20)) self.tick() self.tick() self.task.result()
def when_connection_is_closed(self): self.server.send_method( 0, spec.ConnectionClose(123, 'you muffed up', 10, 20)) self.tick() self.was_closed = self.channel.is_closed()
def it_should_send_ConnectionClose_with_no_exception(self): expected = spec.ConnectionClose(0, 'Connection closed by application', 0, 0) self.server.should_have_received_method(0, expected)
def when_the_close_frame_arrives(self): self.server.send_method( 0, spec.ConnectionClose(123, 'you muffed up', 10, 20))
def given_a_closed_connection(self): self.server.send_method( 0, spec.ConnectionClose(123, 'you muffed up', 10, 20)) self.tick() self.server.reset()
def it_should_send_connection_close(self): self.protocol.send_method.assert_called_once_with( 0, spec.ConnectionClose(501, 'Heartbeat timed out', 0, 0))
def given_a_closed_connection(self): close_frame = asynqp.frames.MethodFrame(0, spec.ConnectionClose(123, 'you muffed up', 10, 20)) self.dispatcher.dispatch(close_frame) self.tick() self.mock_writer = mock.Mock()