예제 #1
0
파일: tests.py 프로젝트: diorahman/nydus
class RoundRobinTest(BaseTest):
    def setUp(self):
        self.router = RoundRobinRouter()
        self.hosts = dict((i, DummyConnection(i)) for i in range(5))
        self.cluster = Cluster(router=self.router, hosts=self.hosts)

    def get_db(self, *args, **kwargs):
        kwargs.setdefault('cluster', self.cluster)
        return self.router.get_db(*args, **kwargs)

    def test_cluster_of_zero_returns_zero(self):
        self.cluster.hosts = dict()
        self.assertEquals([], self.get_db())

    def test_cluster_of_one_returns_one(self):
        self.cluster.hosts = {0: DummyConnection('foo')}
        self.assertEquals([0], self.get_db())

    def test_multi_node_cluster_returns_correct_host(self):
        self.cluster.hosts = {
            0: DummyConnection('foo'),
            1: DummyConnection('bar')
        }
        self.assertEquals([[0], [1], [0], [1]], [
            self.get_db(),
            self.get_db(),
            self.get_db(),
            self.get_db(),
        ])
예제 #2
0
파일: tests.py 프로젝트: diorahman/nydus
class RoundRobinRouterTest(BaseTest):
    def setUp(self):
        self.router = RoundRobinRouter()
        self.hosts = dict((i, DummyConnection(i)) for i in range(5))
        self.cluster = Cluster(router=self.router, hosts=self.hosts)

    def get_db(self, *args, **kwargs):
        kwargs.setdefault('cluster', self.cluster)
        return self.router.get_db(*args, **kwargs)
예제 #3
0
파일: tests.py 프로젝트: diorahman/nydus
class RoundRobinRouterTest(BaseTest):

    def setUp(self):
        self.router = RoundRobinRouter()
        self.hosts = dict((i, DummyConnection(i)) for i in range(5))
        self.cluster = Cluster(router=self.router, hosts=self.hosts)

    def get_db(self, *args, **kwargs):
        kwargs.setdefault('cluster', self.cluster)
        return self.router.get_db(*args, **kwargs)
예제 #4
0
파일: tests.py 프로젝트: diorahman/nydus
class RoundRobinTest(BaseTest):

    def setUp(self):
        self.router = RoundRobinRouter()
        self.hosts = dict((i, DummyConnection(i)) for i in range(5))
        self.cluster = Cluster(router=self.router, hosts=self.hosts)

    def get_db(self, *args, **kwargs):
        kwargs.setdefault('cluster', self.cluster)
        return self.router.get_db(*args, **kwargs)

    def test_cluster_of_zero_returns_zero(self):
        self.cluster.hosts = dict()
        self.assertEquals([], self.get_db())

    def test_cluster_of_one_returns_one(self):
        self.cluster.hosts = {0: DummyConnection('foo')}
        self.assertEquals([0], self.get_db())

    def test_multi_node_cluster_returns_correct_host(self):
        self.cluster.hosts = {0: DummyConnection('foo'), 1: DummyConnection('bar')}
        self.assertEquals([[0], [1], [0], [1]], [self.get_db(), self.get_db(), self.get_db(), self.get_db(), ])
예제 #5
0
파일: tests.py 프로젝트: diorahman/nydus
 def setUp(self):
     self.router = RoundRobinRouter()
     self.hosts = dict((i, DummyConnection(i)) for i in range(5))
     self.cluster = Cluster(router=self.router, hosts=self.hosts)
예제 #6
0
파일: tests.py 프로젝트: diorahman/nydus
 def setUp(self):
     self.router = RoundRobinRouter()
     self.hosts = dict((i, DummyConnection(i)) for i in range(5))
     self.cluster = Cluster(router=self.router, hosts=self.hosts)