예제 #1
0
 def setUp(self):
     self.channel = _Channel()
예제 #2
0
 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()
예제 #3
0
 def test_channel_fileno_with_socket(self):
     sock = socket.socket()
     channel = _Channel(socket=sock)
     self.assertTrue(channel.fileno == sock.fileno())
예제 #4
0
 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)
예제 #5
0
 def test_channel_fileno_with_no_socket(self):
     channel = _Channel()
     self.assertTrue(channel.fileno is None)
예제 #6
0
 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()
예제 #7
0
 def setUp(self):
     self.channel = _Channel()
     self.sock = MagicMock()
     self.channel._socket = self.sock
예제 #8
0
 def test_channel_constructor_engine_arg(self):
     engine = Engine()
     channel = _Channel(engine=engine)
     self.assertTrue(channel.engine is engine)
예제 #9
0
 def setUp(self):
     self._sendfile = pants._channel.sendfile
     self.channel = _Channel()
예제 #10
0
 def test_channel_constructor_socket_arg(self):
     sock = socket.socket()
     channel = _Channel(socket=sock)
     self.assertTrue(channel._socket is sock)
예제 #11
0
 def test_channel_constructor_no_args(self):
     channel = _Channel()
     self.assertTrue(channel.engine is Engine.instance())
     self.assertTrue(channel._socket is None)
예제 #12
0
 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)