コード例 #1
0
ファイル: testConnectionPool.py プロジェクト: Nexedi/neoppod
 def test_iterateForObject_noStorageAvailable(self):
     # no node available
     oid = self.getOID(1)
     app = Mock()
     app.pt = Mock({"getCellList": []})
     pool = ConnectionPool(app)
     self.assertRaises(NEOStorageError, pool.iterateForObject(oid).next)
コード例 #2
0
 def test_iterateForObject_noStorageAvailable(self):
     # no node available
     oid = self.getOID(1)
     app = Mock()
     app.pt = Mock({'getCellList': []})
     pool = ConnectionPool(app)
     self.assertRaises(NEOStorageError, pool.iterateForObject(oid).next)
コード例 #3
0
ファイル: testConnectionPool.py プロジェクト: Nexedi/neoppod
 def test_iterateForObject_connectionAccepted(self):
     # connection accepted
     oid = self.getOID(1)
     node = Mock({"__repr__": "node", "isRunning": True})
     cell = Mock({"__repr__": "cell", "getNode": node})
     conn = Mock({"__repr__": "conn"})
     app = Mock()
     app.pt = Mock({"getCellList": [cell]})
     pool = ConnectionPool(app)
     pool.getConnForNode = Mock({"__call__": conn})
     self.assertEqual(list(pool.iterateForObject(oid)), [(node, conn)])
コード例 #4
0
ファイル: testConnectionPool.py プロジェクト: Nexedi/neoppod
 def test_iterateForObject_connectionRefused(self):
     # connection refused at the first try
     oid = self.getOID(1)
     node = Mock({"__repr__": "node", "isRunning": True})
     cell = Mock({"__repr__": "cell", "getNode": node})
     conn = Mock({"__repr__": "conn"})
     app = Mock()
     app.pt = Mock({"getCellList": [cell]})
     pool = ConnectionPool(app)
     pool.getConnForNode = Mock({"__call__": ReturnValues(None, conn)})
     self.assertEqual(list(pool.iterateForObject(oid)), [(node, conn)])
コード例 #5
0
 def test_iterateForObject_connectionRefused(self):
     # connection refused at the first try
     oid = self.getOID(1)
     node = Mock({'__repr__': 'node', 'isRunning': True})
     cell = Mock({'__repr__': 'cell', 'getNode': node})
     conn = Mock({'__repr__': 'conn'})
     app = Mock()
     app.pt = Mock({'getCellList': [cell]})
     pool = ConnectionPool(app)
     pool.getConnForNode = Mock({'__call__': ReturnValues(None, conn)})
     self.assertEqual(list(pool.iterateForObject(oid)), [(node, conn)])
コード例 #6
0
 def test_iterateForObject_connectionAccepted(self):
     # connection accepted
     oid = self.getOID(1)
     node = Mock({'__repr__': 'node', 'isRunning': True})
     cell = Mock({'__repr__': 'cell', 'getNode': node})
     conn = Mock({'__repr__': 'conn'})
     app = Mock()
     app.pt = Mock({'getCellList': [cell]})
     pool = ConnectionPool(app)
     pool.getConnForNode = Mock({'__call__': conn})
     self.assertEqual(list(pool.iterateForObject(oid)), [(node, conn)])