# Path: mozsvc/tests/support.py
# class TestCase(unittest2.TestCase):
#     """TestCase with some generic helper methods."""
# 
#     def setUp(self):
#         super(TestCase, self).setUp()
#         self.config = self.get_configurator()
# 
#     def tearDown(self):
#         self.config.end()
#         super(TestCase, self).tearDown()
# 
#     def get_configurator(self):
#         """Load the configurator to use for the tests."""
#         # Load config from the .ini file.
#         if not hasattr(self, "ini_file"):
#             if hasattr(self, "TEST_INI_FILE"):
#                 self.ini_file = self.TEST_INI_FILE
#             else:
#                 # The file to use may be specified in the environment.
#                 self.ini_file = os.environ.get("MOZSVC_TEST_INI_FILE",
#                                                "tests.ini")
#         __file__ = sys.modules[self.__class__.__module__].__file__
#         config = get_test_configurator(__file__, self.ini_file)
#         config.begin()
#         return config
# 
#     def make_request(self, *args, **kwds):
#         config = kwds.pop("config", self.config)
#         return make_request(config, *args, **kwds)
# 
# Path: shavar/types.py
# class Chunk(object):
#     "Object for ease of interacting with parsed chunk data"
# 
#     def __init__(self, chunk_type='a', number=None, hashes=[], hash_size=32):
#         if chunk_type not in ('a', 's'):
#             raise ValueError('Invalid chunk type: "%s"' % chunk_type)
# 
#         if number is None:
#             raise ValueError('Invalid chunk number: "%d"' % number)
# 
#         self.type = chunk_type
#         self.number = number
#         self.hashes = set(hashes)
#         self.hash_len = hash_size
#         self._prefix_cache = {}
# 
#     def __repr__(self):
#         return "%s(chunk_type='%s', number=%d, hashes=%s, hash_size=%d)" \
#             % (self.__class__.__name__, self.type, self.number, self.hashes,
#                self.hash_len)
# 
#     def __eq__(self, other):
#         if (type(self) != type(other)
#                 or self.type != other.type
#                 or self.number != other.number
#                 or self.hashes != other.hashes
#                 or self.hash_len != other.hash_len):
#             return False
#         return True
# 
#     def find_prefix(self, prefix):
#         if prefix in self._prefix_cache:
#             return True
#         for hash_ in self.hashes:
#             if hash_.startswith(prefix):
#                 self._prefix_cache[prefix] = True
#                 return True
#         return False
# 
#     def get_hashes(self, prefix):
#         hashes = []
#         for hash_ in self.hashes:
#             if hash_.startswith(prefix):
#                 hashes.append(hash_)
#         return hashes
# 
# class ChunkList(object):
#     "Simplify interaction with server side lists of chunks"
# 
#     def __init__(self, add_chunks=[], sub_chunks=[]):
#         self.adds = {}
#         self.subs = {}
#         for chunk in add_chunks:
#             self.adds[chunk.number] = chunk
#         for chunk in sub_chunks:
#             self.subs[chunk.number] = chunk
# 
#     def __repr__(self):
#         return "%s(add_chunks=%s, sub_chunks=%s)" \
#             % (self.__class__.__name__,
#                list(self.adds.values()),
#                list(self.subs.values()))
# 
#     def __eq__(self, other):
#         if (type(self) != type(other)
#                 or self.adds != other.adds
#                 or self.subs != other.subs):
#             return False
#         return True
# 
#     def __len__(self):
#         return len(self.adds) + len(self.subs)
# 
#     def find_prefix(self, prefix):
#         list_o_chunks = []
#         for number, chunk in self.adds.items():
#             if chunk.find_prefix(prefix):
#                 list_o_chunks.append(chunk)
#         return list_o_chunks
# 
#     def insert_chunk(self, chunk):
#         chunk_list = self.adds
#         if chunk.type == 's':
#             chunk_list = self.subs
#         if chunk.number in chunk_list:
#             raise ValueError("Duplicate chunk number: %d" % chunk.number)
#         chunk_list[chunk.number] = chunk


import hashlib
import io
import os.path
from pyramid import testing
from mozsvc.tests.support import TestCase
from shavar.types import Chunk, ChunkList
    return DummyRequest(params=params, body=body_in_bytes)


def test_file(fname):
    return os.path.join(os.path.dirname(__file__), fname)


# Ensure that test runners don't think this is an actual testcase.
test_file.__test__ = False


class ShavarTestCase(TestCase):

    hm = hashes['moz']
    hg = hashes['goog']
    _d = b''.join([hm, hg])
    add = b"a:17:32:%d\n%s" % (len(_d), _d)
    sub = b"s:18:32:%d\n%s" % (len(_d), _d)

    def setUp(self):
        self.maxDiff = None
        super(ShavarTestCase, self).setUp()

    def get_configurator(self):
        config = super(ShavarTestCase, self).get_configurator()
        config.include("shavar")
        return config


def chunkit(n, typ, *urls):

# Path: mozsvc/tests/support.py
# class TestCase(unittest2.TestCase):
#     """TestCase with some generic helper methods."""
# 
#     def setUp(self):
#         super(TestCase, self).setUp()
#         self.config = self.get_configurator()
# 
#     def tearDown(self):
#         self.config.end()
#         super(TestCase, self).tearDown()
# 
#     def get_configurator(self):
#         """Load the configurator to use for the tests."""
#         # Load config from the .ini file.
#         if not hasattr(self, "ini_file"):
#             if hasattr(self, "TEST_INI_FILE"):
#                 self.ini_file = self.TEST_INI_FILE
#             else:
#                 # The file to use may be specified in the environment.
#                 self.ini_file = os.environ.get("MOZSVC_TEST_INI_FILE",
#                                                "tests.ini")
#         __file__ = sys.modules[self.__class__.__module__].__file__
#         config = get_test_configurator(__file__, self.ini_file)
#         config.begin()
#         return config
# 
#     def make_request(self, *args, **kwds):
#         config = kwds.pop("config", self.config)
#         return make_request(config, *args, **kwds)
# 
# Path: shavar/types.py
# class Chunk(object):
#     "Object for ease of interacting with parsed chunk data"
# 
#     def __init__(self, chunk_type='a', number=None, hashes=[], hash_size=32):
#         if chunk_type not in ('a', 's'):
#             raise ValueError('Invalid chunk type: "%s"' % chunk_type)
# 
#         if number is None:
#             raise ValueError('Invalid chunk number: "%d"' % number)
# 
#         self.type = chunk_type
#         self.number = number
#         self.hashes = set(hashes)
#         self.hash_len = hash_size
#         self._prefix_cache = {}
# 
#     def __repr__(self):
#         return "%s(chunk_type='%s', number=%d, hashes=%s, hash_size=%d)" \
#             % (self.__class__.__name__, self.type, self.number, self.hashes,
#                self.hash_len)
# 
#     def __eq__(self, other):
#         if (type(self) != type(other)
#                 or self.type != other.type
#                 or self.number != other.number
#                 or self.hashes != other.hashes
#                 or self.hash_len != other.hash_len):
#             return False
#         return True
# 
#     def find_prefix(self, prefix):
#         if prefix in self._prefix_cache:
#             return True
#         for hash_ in self.hashes:
#             if hash_.startswith(prefix):
#                 self._prefix_cache[prefix] = True
#                 return True
#         return False
# 
#     def get_hashes(self, prefix):
#         hashes = []
#         for hash_ in self.hashes:
#             if hash_.startswith(prefix):
#                 hashes.append(hash_)
#         return hashes
# 
# class ChunkList(object):
#     "Simplify interaction with server side lists of chunks"
# 
#     def __init__(self, add_chunks=[], sub_chunks=[]):
#         self.adds = {}
#         self.subs = {}
#         for chunk in add_chunks:
#             self.adds[chunk.number] = chunk
#         for chunk in sub_chunks:
#             self.subs[chunk.number] = chunk
# 
#     def __repr__(self):
#         return "%s(add_chunks=%s, sub_chunks=%s)" \
#             % (self.__class__.__name__,
#                list(self.adds.values()),
#                list(self.subs.values()))
# 
#     def __eq__(self, other):
#         if (type(self) != type(other)
#                 or self.adds != other.adds
#                 or self.subs != other.subs):
#             return False
#         return True
# 
#     def __len__(self):
#         return len(self.adds) + len(self.subs)
# 
#     def find_prefix(self, prefix):
#         list_o_chunks = []
#         for number, chunk in self.adds.items():
#             if chunk.find_prefix(prefix):
#                 list_o_chunks.append(chunk)
#         return list_o_chunks
# 
#     def insert_chunk(self, chunk):
#         chunk_list = self.adds
#         if chunk.type == 's':
#             chunk_list = self.subs
#         if chunk.number in chunk_list:
#             raise ValueError("Duplicate chunk number: %d" % chunk.number)
#         chunk_list[chunk.number] = chunk


# Path: shavar/tests/base.py
import hashlib
import io
import os.path
from pyramid import testing
from mozsvc.tests.support import TestCase
from shavar.types import Chunk, ChunkList

    return DummyRequest(params=params, body=body_in_bytes)


def test_file(fname):
    return os.path.join(os.path.dirname(__file__), fname)


# Ensure that test runners don't think this is an actual testcase.
test_file.__test__ = False


class ShavarTestCase(TestCase):

    hm = hashes['moz']
    hg = hashes['goog']
    _d = b''.join([hm, hg])
    add = b"a:17:32:%d\n%s" % (len(_d), _d)
    sub = b"s:18:32:%d\n%s" % (len(_d), _d)

    def setUp(self):
        self.maxDiff = None
        super(ShavarTestCase, self).setUp()

    def get_configurator(self):
        config = super(ShavarTestCase, self).get_configurator()
        config.include("shavar")
        return config


def chunkit(n, typ, *urls):

    return Chunk(number=n, chunk_type=typ,