# 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
        fake_1_nodes = ring.get_nodes(b'fake', replicas=3)
        fake_2_nodes = ring.get_nodes(b'fake-again', replicas=3)
        # We should have one nodes for each thing
        self.assertEqual(3, len(fake_1_nodes))
        self.assertEqual(3, len(fake_2_nodes))
        self.assertEqual(fake_1_nodes, fake_2_nodes)

    def test_ignore_nodes(self):
        nodes = ['foo', 'bar', 'baz']
        ring = hashring.HashRing(nodes)
        equals_bar_or_baz = matchers.MatchesAny(
            matchers.Equals({'bar'}),
            matchers.Equals({'baz'}))
        self.assertThat(
            ring.get_nodes(b'fake', ignore_nodes=['foo']),
            equals_bar_or_baz)
        self.assertThat(
            ring.get_nodes(b'fake', ignore_nodes=['foo', 'bar']),
            equals_bar_or_baz)
        self.assertEqual(set(), ring.get_nodes(b'fake', ignore_nodes=nodes))

    @staticmethod
    def _compare_rings(nodes, conductors, ring, new_conductors, new_ring):
        delta = {}
        mapping = {
            'node': list(ring.get_nodes(node.encode('ascii')))[0]
            for node in nodes
        }
        new_mapping = {
            'node': list(new_ring.get_nodes(node.encode('ascii')))[0]

# 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

        fake_1_nodes = ring.get_nodes(b'fake', replicas=3)
        fake_2_nodes = ring.get_nodes(b'fake-again', replicas=3)
        # We should have one nodes for each thing
        self.assertEqual(3, len(fake_1_nodes))
        self.assertEqual(3, len(fake_2_nodes))
        self.assertEqual(fake_1_nodes, fake_2_nodes)

    def test_ignore_nodes(self):
        nodes = ['foo', 'bar', 'baz']
        ring = hashring.HashRing(nodes)
        equals_bar_or_baz = matchers.MatchesAny(
            matchers.Equals({'bar'}),
            matchers.Equals({'baz'}))
        self.assertThat(
            ring.get_nodes(b'fake', ignore_nodes=['foo']),
            equals_bar_or_baz)
        self.assertThat(
            ring.get_nodes(b'fake', ignore_nodes=['foo', 'bar']),
            equals_bar_or_baz)
        self.assertEqual(set(), ring.get_nodes(b'fake', ignore_nodes=nodes))

    @staticmethod
    def _compare_rings(nodes, conductors, ring, new_conductors, new_ring):
        delta = {}
        mapping = {
            'node': list(ring.get_nodes(node.encode('ascii')))[0]
            for node in nodes
        }
        new_mapping = {
            'node': list(new_ring.get_nodes(node.encode('ascii')))[0]

            for node in nodes