Example #1
0
 def test_with_cluster(self, get):
     p = BaseCluster(
         backend=Memcache,
         hosts={0: {}},
     )
     result = p.get('MemcacheTest_with_cluster')
     get.assert_called_once_with('MemcacheTest_with_cluster')
     self.assertEqual(result, get.return_value)
Example #2
0
File: tests.py Project: tupy/nydus
 def test_proxy(self):
     p = BaseCluster(
         backend=DummyConnection,
         hosts={0: {
             'resp': 'bar'
         }},
     )
     self.assertEquals(p.foo(), 'bar')
Example #3
0
 def test_with_cluster(self):
     p = BaseCluster(
         backend=Redis,
         hosts={0: {
             'db': 1
         }},
     )
     self.assertEquals(p.incr('RedisTest_with_cluster'), 1)
Example #4
0
File: tests.py Project: thoas/nydus
 def test_with_cluster(self, get):
     p = BaseCluster(
         backend=Memcache,
         hosts={0: {}},
     )
     result = p.get('MemcacheTest_with_cluster')
     get.assert_called_once_with('MemcacheTest_with_cluster')
     self.assertEqual(result, get.return_value)
Example #5
0
File: tests.py Project: thoas/nydus
 def test_disconnect(self):
     c = mock.Mock()
     p = BaseCluster(
         backend=c,
         hosts={0: {'resp': 'bar'}},
     )
     p.disconnect()
     c.disconnect.assert_called_once()
Example #6
0
File: tests.py Project: tupy/nydus
 def test_disconnect(self):
     c = mock.Mock()
     p = BaseCluster(
         backend=c,
         hosts={0: {
             'resp': 'bar'
         }},
     )
     p.disconnect()
     c.disconnect.assert_called_once()
Example #7
0
File: tests.py Project: thoas/nydus
 def test_default_routing_with_multiple_hosts(self):
     p = BaseCluster(
         backend=DummyConnection,
         hosts={
             0: {'resp': 'foo'},
             1: {'resp': 'bar'},
         },
     )
     self.assertEqual(p.foo(), ['foo', 'bar'])
     self.assertEqual(p.foo('foo'), ['foo', 'bar'])
Example #8
0
File: tests.py Project: thoas/nydus
 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])
Example #9
0
File: tests.py Project: thoas/nydus
 def test_with_split_router(self):
     p = BaseCluster(
         router=DummyRouter,
         backend=DummyConnection,
         hosts={
             0: {'resp': 'foo'},
             1: {'resp': 'bar'},
         },
     )
     self.assertEqual(p.foo(), 'foo')
     self.assertEqual(p.foo('foo'), 'bar')
Example #10
0
File: tests.py Project: thoas/nydus
 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)
Example #11
0
File: tests.py Project: tupy/nydus
 def test_default_routing_with_multiple_hosts(self):
     p = BaseCluster(
         backend=DummyConnection,
         hosts={
             0: {
                 'resp': 'foo'
             },
             1: {
                 'resp': 'bar'
             },
         },
     )
     self.assertEquals(p.foo(), ['foo', 'bar'])
     self.assertEquals(p.foo('foo'), ['foo', 'bar'])
Example #12
0
File: tests.py Project: tupy/nydus
 def test_with_split_router(self):
     p = BaseCluster(
         router=DummyRouter,
         backend=DummyConnection,
         hosts={
             0: {
                 'resp': 'foo'
             },
             1: {
                 'resp': 'bar'
             },
         },
     )
     self.assertEquals(p.foo(), 'foo')
     self.assertEquals(p.foo('foo'), 'bar')
Example #13
0
File: tests.py Project: tupy/nydus
 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])
Example #14
0
File: tests.py Project: tupy/nydus
 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)
Example #15
0
File: tests.py Project: tupy/nydus
 def cluster(self):
     return BaseCluster(
         backend=DummyConnection,
         hosts={
             0: {
                 'resp': 'foo'
             },
             1: {
                 'resp': 'bar'
             },
         },
     )
Example #16
0
File: tests.py Project: tupy/nydus
 def cluster(self):
     return BaseCluster(
         backend=DummyErroringConnection,
         hosts={
             0: {
                 'resp': 'foo'
             },
             1: {
                 'resp': 'error'
             },
         },
         router=DummyRouter,
     )
Example #17
0
File: tests.py Project: tupy/nydus
 def test_len_returns_num_backends(self):
     p = BaseCluster(
         backend=BaseConnection,
         hosts={0: {}},
     )
     self.assertEquals(len(p), 1)
Example #18
0
File: tests.py Project: thoas/nydus
 def test_proxy(self):
     p = BaseCluster(
         backend=DummyConnection,
         hosts={0: {'resp': 'bar'}},
     )
     self.assertEqual(p.foo(), 'bar')
Example #19
0
 def test_with_cluster(self):
     p = BaseCluster(
         hosts={0: self.redis},
     )
     self.assertEquals(p.incr('RedisTest_with_cluster'), 1)
Example #20
0
 def test_with_cluster(self):
     p = BaseCluster(
         backend=Redis,
         hosts={0: {'db': 1}},
     )
     self.assertEquals(p.incr('RedisTest_with_cluster'), 1)
Example #21
0
 def setUp(self):
     self.hosts = dict((i, {}) for i in xrange(5))
     self.cluster = BaseCluster(router=self.Router,
                                hosts=self.hosts,
                                backend=DummyConnection)
     self.router = self.cluster.router
Example #22
0
 def test_with_cluster(self):
     p = BaseCluster(hosts={0: self.memcache})
     self.assertEquals(p.get('MemcacheTest_with_cluster'), None)