# Path: pydoop/mapreduce/binary_protocol.py
# OUTPUT = 50
# 
# PARTITIONED_OUTPUT = 51


import io
import os
import shutil
import struct
import tempfile
import unittest
import uuid
import pydoop.sercore as sercore
from random import randint
from pydoop.mapreduce.binary_protocol import OUTPUT, PARTITIONED_OUTPUT
    def test_string_as_bytes(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_string(self.STRING)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_bytes(), self.STRING.encode("utf8"))

    def test_bytes_as_string(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_bytes(self.BYTES)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_string(), self.BYTES.decode("utf8"))

    def test_bytes_as_bytes(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_bytes(self.BYTES)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_bytes(), self.BYTES)

    def test_output(self):
        k, v = b"key", b"value"
        with sercore.FileOutStream(self.fname) as s:
            s.write_output(k, v)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_vint(), OUTPUT)
            self.assertEqual(s.read_bytes(), k)
            self.assertEqual(s.read_bytes(), v)
        part = 1
        with sercore.FileOutStream(self.fname) as s:
            s.write_output(k, v, part)
        with sercore.FileInStream(self.fname) as s:

# Path: pydoop/mapreduce/binary_protocol.py
# OUTPUT = 50
# 
# PARTITIONED_OUTPUT = 51


# Path: test/sercore/test_streams.py
import io
import os
import shutil
import struct
import tempfile
import unittest
import uuid
import pydoop.sercore as sercore
from random import randint
from pydoop.mapreduce.binary_protocol import OUTPUT, PARTITIONED_OUTPUT

    def test_string_as_bytes(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_string(self.STRING)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_bytes(), self.STRING.encode("utf8"))

    def test_bytes_as_string(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_bytes(self.BYTES)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_string(), self.BYTES.decode("utf8"))

    def test_bytes_as_bytes(self):
        with sercore.FileOutStream(self.fname) as s:
            s.write_bytes(self.BYTES)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_bytes(), self.BYTES)

    def test_output(self):
        k, v = b"key", b"value"
        with sercore.FileOutStream(self.fname) as s:
            s.write_output(k, v)
        with sercore.FileInStream(self.fname) as s:
            self.assertEqual(s.read_vint(), OUTPUT)
            self.assertEqual(s.read_bytes(), k)
            self.assertEqual(s.read_bytes(), v)
        part = 1
        with sercore.FileOutStream(self.fname) as s:
            s.write_output(k, v, part)
        with sercore.FileInStream(self.fname) as s:

            self.assertEqual(s.read_vint(), PARTITIONED_OUTPUT)