# Path: kiel/compression/snappy.py
# DEFAULT_VERSION = 1
# MIN_COMPAT_VERSION = 1
# MAGIC_HEADER = (
#     -126, b'S', b'N', b'A', b'P', b'P', b'Y', 0,
#     DEFAULT_VERSION, MIN_COMPAT_VERSION
# )
# BLOCK_SIZE = 32 * 1024  # 32kb, in bytes
# def compress(data):
# def decompress(data):


import json
import struct
import unittest
from mock import patch
from kiel.compression import snappy




@unittest.skipUnless(snappy.snappy_available, "requires python-snappy")
class SnappyCompressionTests(unittest.TestCase):

    @patch.object(snappy, "snappy_available", False)
    def test_compress_runtime_error_if_snappy_unavailable(self):
        self.assertRaises(
            RuntimeError,
            snappy.compress, "foo"
        )

    @patch.object(snappy, "snappy_available", False)
    def test_decompress_runtime_error_if_snappy_unavailable(self):
        self.assertRaises(
            RuntimeError,
            snappy.decompress, "foo"
        )

    def test_compression_is_stable(self):
        data = json.dumps({"foo": "bar", "dog": "cat"}).encode("utf-8")


# Path: kiel/compression/snappy.py
# DEFAULT_VERSION = 1
# MIN_COMPAT_VERSION = 1
# MAGIC_HEADER = (
#     -126, b'S', b'N', b'A', b'P', b'P', b'Y', 0,
#     DEFAULT_VERSION, MIN_COMPAT_VERSION
# )
# BLOCK_SIZE = 32 * 1024  # 32kb, in bytes
# def compress(data):
# def decompress(data):


# Path: tests/compression/test_snappy.py
import json
import struct
import unittest
from mock import patch
from kiel.compression import snappy





@unittest.skipUnless(snappy.snappy_available, "requires python-snappy")
class SnappyCompressionTests(unittest.TestCase):

    @patch.object(snappy, "snappy_available", False)
    def test_compress_runtime_error_if_snappy_unavailable(self):
        self.assertRaises(
            RuntimeError,
            snappy.compress, "foo"
        )

    @patch.object(snappy, "snappy_available", False)
    def test_decompress_runtime_error_if_snappy_unavailable(self):
        self.assertRaises(
            RuntimeError,
            snappy.decompress, "foo"
        )

    def test_compression_is_stable(self):
        data = json.dumps({"foo": "bar", "dog": "cat"}).encode("utf-8")


        data = snappy.compress(data)