Exemplo n.º 1
0
    def test_handle_write_with_empty(self):
        mock_target = mock.Mock()
        mock_target.buffers = []

        EchoClient.handle_write(mock_target)

        self.assertFalse(mock_target.send.called)
Exemplo n.º 2
0
    def test_bind_all(self):
        mock_target = mock.Mock()

        EchoClient.bind_all(mock_target)

        mock_target.view.entry.bind.assert_called_with('<Return>',
                                                       mock_target.on_submit)
Exemplo n.º 3
0
    def test_handle_write_with_empty(self):
        mock_target = mock.Mock()
        mock_target.buffers = []
        
        EchoClient.handle_write(mock_target)

        self.assertFalse(mock_target.send.called)
Exemplo n.º 4
0
    def test_handle_reade(self):
        mock_target = mock.Mock()
        mock_target.recv.return_value = b'test'

        EchoClient.handle_read(mock_target)

        mock_target.recv.assert_called_with(8192)
        mock_target.view.show_message.assert_called_with('test')
Exemplo n.º 5
0
    def test_handle_write(self):
        mock_target = mock.Mock()
        mock_target.buffers = [b'a', b'b']

        EchoClient.handle_write(mock_target)

        self.assertEqual(mock_target.buffers, [b'b'])
        mock_target.send.assert_called_with(b'a')
Exemplo n.º 6
0
    def test_on_submit(self):
        mock_target = mock.Mock()
        mock_target.view.get_submit_messegae.return_value = 'test-data'
        mock_target.buffers = []

        EchoClient.on_submit(mock_target, mock.Mock())

        self.assertEqual(mock_target.buffers, [b'test-data'])
Exemplo n.º 7
0
    def test_handle_reade(self):
        mock_target = mock.Mock()
        mock_target.recv.return_value = b'test'

        EchoClient.handle_read(mock_target)

        mock_target.recv.assert_called_with(8192)
        mock_target.view.show_message.assert_called_with('test')
Exemplo n.º 8
0
    def test_handle_write(self):
        mock_target = mock.Mock()
        mock_target.buffers = [b'a', b'b']

        EchoClient.handle_write(mock_target)

        self.assertEqual(mock_target.buffers, [b'b'])        
        mock_target.send.assert_called_with(b'a')
Exemplo n.º 9
0
    def test_on_submit(self):
        mock_target = mock.Mock()
        mock_target.view.get_submit_messegae.return_value = 'test-data'
        mock_target.buffers = []

        EchoClient.on_submit(mock_target, mock.Mock())

        self.assertEqual(mock_target.buffers, [b'test-data'])
Exemplo n.º 10
0
    def test_writable(self):
        mock_target = mock.Mock()
        mock_target.buffers = ['a']

        result = EchoClient.writable(mock_target)

        self.assertIs(result, True)
Exemplo n.º 11
0
    def test_writable_with_empty(self):
        mock_target = mock.Mock()
        mock_target.buffers = []

        result = EchoClient.writable(mock_target)

        self.assertIs(result, False)
Exemplo n.º 12
0
    def test_writable(self):
        mock_target = mock.Mock()
        mock_target.buffers = ['a']

        result = EchoClient.writable(mock_target)

        self.assertIs(result, True)
Exemplo n.º 13
0
    def test_writable_with_empty(self):
        mock_target = mock.Mock()
        mock_target.buffers = []

        result = EchoClient.writable(mock_target)

        self.assertIs(result, False)
Exemplo n.º 14
0
    def test_init(self):
        EchoClient.create_socket = mock.Mock()
        EchoClient.bind_all = mock.Mock()

        mock_view = mock.Mock()
        result = EchoClient(mock_view)

        self.assertEqual(result.view, mock_view)
        self.assertEqual(result.buffers, [])
        EchoClient.create_socket.assert_called_with()
        EchoClient.bind_all.assert_called_with()
Exemplo n.º 15
0
    def test_bind_all(self):
        mock_target = mock.Mock()

        EchoClient.bind_all(mock_target)

        mock_target.view.entry.bind.assert_called_with('<Return>', mock_target.on_submit)