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)
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)
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)])
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)])
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)])
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)])