Ejemplo n.º 1
0
    def test_unix_socket_stream_support(self):
        mock_digest = self.mocker.mock()
        mock_digest(mocker.ANY)
        self.mocker.result("e5fcf4f4606df6368779205e29b22e5851355de3")
        self.mocker.replay()

        out_stream = utils.get_readable_socket(self.sock_path)
        in_stream = utils.get_writable_socket(self.sock_path)

        in_stream.sendall(self.serialized_message)
        messages = utils.recv_messages(out_stream, mock_digest)

        self.assertEqual(messages.next(), "message")
Ejemplo n.º 2
0
    def test_unix_socket_stream_support(self):
        import socket

        mock_digest = self.mocker.mock()
        mock_pickle = self.mocker.mock()
        mock_digest(mocker.ANY)
        self.mocker.result("e5fcf4f4606df6368779205e29b22e5851355de3")

        mock_pickle.HIGHEST_PROTOCOL
        self.mocker.result("foo")

        mock_pickle.dumps(mocker.ANY, mocker.ANY)
        self.mocker.result("serialized-data-byte-string")

        self.mocker.replay()

        out_stream = utils.get_readable_socket(self.sock_path)
        out_stream.setblocking(1)  # avoid blocking
        in_stream = utils.get_writable_socket(self.sock_path)

        utils.send_message(in_stream, "message", mock_digest, pickle_dep=mock_pickle)
        conn, _ = out_stream.accept()
        self.assertEqual(int(conn.recv(1024).split("\n")[0].split(" ")[1]), len("serialized-data-byte-string"))