def test_get_conn_default_routing_with_multiple_hosts(self): # test default routing behavior p = BaseCluster( backend=DummyConnection, hosts={ 0: {'resp': 'foo'}, 1: {'resp': 'bar'}, }, ) self.assertEqual(list(map(lambda x: x.num, p.get_conn())), [0, 1]) self.assertEqual(list(map(lambda x: x.num, p.get_conn('foo'))), [0, 1])
def test_get_conn_with_split_router(self): # test dummy router p = BaseCluster( backend=DummyConnection, hosts={ 0: {'resp': 'foo'}, 1: {'resp': 'bar'}, }, router=DummyRouter, ) self.assertEqual(p.get_conn().num, 0) self.assertEqual(p.get_conn('foo').num, 1)
def test_get_conn_default_routing_with_multiple_hosts(self): # test default routing behavior p = BaseCluster( backend=DummyConnection, hosts={ 0: { 'resp': 'foo' }, 1: { 'resp': 'bar' }, }, ) self.assertEquals(map(lambda x: x.num, p.get_conn()), [0, 1]) self.assertEquals(map(lambda x: x.num, p.get_conn('foo')), [0, 1])
def test_get_conn_with_split_router(self): # test dummy router p = BaseCluster( backend=DummyConnection, hosts={ 0: { 'resp': 'foo' }, 1: { 'resp': 'bar' }, }, router=DummyRouter, ) self.assertEquals(p.get_conn().num, 0) self.assertEquals(p.get_conn('foo').num, 1)