def setUp(self): self.channel = _Channel()
def setUp(self): self.channel = _Channel() self.channel._handle_read_event = MagicMock() self.channel._handle_write_event = MagicMock() self.channel._handle_error_event = MagicMock() self.channel._handle_hangup_event = MagicMock()
def test_channel_fileno_with_socket(self): sock = socket.socket() channel = _Channel(socket=sock) self.assertTrue(channel.fileno == sock.fileno())
def test_channel_gets_removed_from_engine(self): engine = Engine() engine.remove_channel = MagicMock() channel = _Channel(socket=socket.socket(), engine=engine) channel.close() engine.remove_channel.assert_called_once_with(channel)
def test_channel_fileno_with_no_socket(self): channel = _Channel() self.assertTrue(channel.fileno is None)
def test_channel_gets_added_to_engine(self): engine = Engine() engine.add_channel = MagicMock() channel = _Channel(socket=socket.socket(), engine=engine) engine.add_channel.assert_called_once_with(channel) channel.close()
def setUp(self): self.channel = _Channel() self.sock = MagicMock() self.channel._socket = self.sock
def test_channel_constructor_engine_arg(self): engine = Engine() channel = _Channel(engine=engine) self.assertTrue(channel.engine is engine)
def setUp(self): self._sendfile = pants._channel.sendfile self.channel = _Channel()
def test_channel_constructor_socket_arg(self): sock = socket.socket() channel = _Channel(socket=sock) self.assertTrue(channel._socket is sock)
def test_channel_constructor_no_args(self): channel = _Channel() self.assertTrue(channel.engine is Engine.instance()) self.assertTrue(channel._socket is None)
def test_bind_is_called(self): channel = _Channel() channel._socket = MagicMock() channel._socket.bind = MagicMock() channel._socket_bind(None) channel._socket.bind.assert_called_once_with(None)