# Path: tooz/hashring.py
# class UnknownNode(tooz.ToozError):
# class HashRing(object):
#     def __init__(self, node):
#     def __init__(self, nodes, partitions=DEFAULT_PARTITION_NUMBER,
#                  hash_function=DEFAULT_HASH_FUNCTION):
#     def add_node(self, node, weight=1):
#     def add_nodes(self, nodes, weight=1):
#     def remove_node(self, node):
#     def _hash2int(key):
#     def _get_partition(self, data):
#     def _get_node(self, partition):
#     def get_nodes(self, data, ignore_nodes=None, replicas=1):
#     def __getitem__(self, key):
#     def __len__(self):
#     DEFAULT_PARTITION_NUMBER = 2**5
#     DEFAULT_HASH_FUNCTION = 'md5'


import hashlib
from unittest import mock
from testtools import matchers
from testtools import testcase
from tooz import hashring
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.discard(b'Z\xe2\xfa\x90\x17EC\xac\xae\x88\xa7[\xa1}:E')
        ring.remove_node(b'Z\xe2\xfa\x90\x17EC\xac\xae\x88\xa7[\xa1}:E')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))

    def test_remove_node_unknown(self):
        nodes = ['foo', 'bar']
        ring = hashring.HashRing(nodes)
        self.assertRaises(
            hashring.UnknownNode,
            ring.remove_node, 'biz')

    def test_add_then_removenode(self):
        nodes = {'foo', 'bar'}
        ring = hashring.HashRing(nodes)
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.add('baz')
        ring.add_node('baz')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.discard('bar')
        ring.remove_node('bar')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))

    def test_distribution_one_replica(self):
        nodes = ['foo', 'bar', 'baz']

# Path: tooz/hashring.py
# class UnknownNode(tooz.ToozError):
# class HashRing(object):
#     def __init__(self, node):
#     def __init__(self, nodes, partitions=DEFAULT_PARTITION_NUMBER,
#                  hash_function=DEFAULT_HASH_FUNCTION):
#     def add_node(self, node, weight=1):
#     def add_nodes(self, nodes, weight=1):
#     def remove_node(self, node):
#     def _hash2int(key):
#     def _get_partition(self, data):
#     def _get_node(self, partition):
#     def get_nodes(self, data, ignore_nodes=None, replicas=1):
#     def __getitem__(self, key):
#     def __len__(self):
#     DEFAULT_PARTITION_NUMBER = 2**5
#     DEFAULT_HASH_FUNCTION = 'md5'


# Path: tooz/tests/test_hashring.py
import hashlib
from unittest import mock
from testtools import matchers
from testtools import testcase
from tooz import hashring

        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.discard(b'Z\xe2\xfa\x90\x17EC\xac\xae\x88\xa7[\xa1}:E')
        ring.remove_node(b'Z\xe2\xfa\x90\x17EC\xac\xae\x88\xa7[\xa1}:E')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))

    def test_remove_node_unknown(self):
        nodes = ['foo', 'bar']
        ring = hashring.HashRing(nodes)
        self.assertRaises(
            hashring.UnknownNode,
            ring.remove_node, 'biz')

    def test_add_then_removenode(self):
        nodes = {'foo', 'bar'}
        ring = hashring.HashRing(nodes)
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.add('baz')
        ring.add_node('baz')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))
        nodes.discard('bar')
        ring.remove_node('bar')
        self.assertEqual(nodes, set(ring.nodes.keys()))
        self.assertEqual(2 ** 5 * len(nodes), len(ring))

    def test_distribution_one_replica(self):
        nodes = ['foo', 'bar', 'baz']

        ring = hashring.HashRing(nodes)