Commit 2a4f6272 authored by Vincent Pelletier's avatar Vincent Pelletier

Fix tests for r2250 and r2242.

r2242 removed the case where we wouldn't be abdle to access the last
version of an object with loadBefore, and its test code is reused here to
check the "not visible" case.
r2250 modified the response in case where an internal error occured.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2254 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent b908563d
...@@ -233,9 +233,8 @@ class ClientApplicationTests(NeoTestBase): ...@@ -233,9 +233,8 @@ class ClientApplicationTests(NeoTestBase):
app.local_var.queue = Mock({'get' : (conn, None)}) app.local_var.queue = Mock({'get' : (conn, None)})
app.pt = Mock({ 'getCellListForOID': [cell, ], }) app.pt = Mock({ 'getCellListForOID': [cell, ], })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
app.local_var.asked_object = -1
Application._waitMessage = self._waitMessage Application._waitMessage = self._waitMessage
self.assertRaises(NEOStorageNotFoundError, app.load, oid) self.assertRaises(NEOStorageError, app.load, oid)
self.checkAskObject(conn) self.checkAskObject(conn)
Application._waitMessage = _waitMessage Application._waitMessage = _waitMessage
# object not found in NEO -> NEOStorageNotFoundError # object not found in NEO -> NEOStorageNotFoundError
...@@ -249,7 +248,6 @@ class ClientApplicationTests(NeoTestBase): ...@@ -249,7 +248,6 @@ class ClientApplicationTests(NeoTestBase):
}) })
app.pt = Mock({ 'getCellListForOID': [cell, ], }) app.pt = Mock({ 'getCellListForOID': [cell, ], })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
app.local_var.asked_object = -1
self.assertRaises(NEOStorageNotFoundError, app.load, oid) self.assertRaises(NEOStorageNotFoundError, app.load, oid)
self.checkAskObject(conn) self.checkAskObject(conn)
# object found on storage nodes and put in cache # object found on storage nodes and put in cache
...@@ -291,7 +289,6 @@ class ClientApplicationTests(NeoTestBase): ...@@ -291,7 +289,6 @@ class ClientApplicationTests(NeoTestBase):
}) })
app.pt = Mock({ 'getCellListForOID': [cell, ], }) app.pt = Mock({ 'getCellListForOID': [cell, ], })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
app.local_var.asked_object = -1
self.assertRaises(NEOStorageNotFoundError, app.loadSerial, oid, tid2) self.assertRaises(NEOStorageNotFoundError, app.loadSerial, oid, tid2)
self.checkAskObject(conn) self.checkAskObject(conn)
# object should not have been cached # object should not have been cached
...@@ -331,12 +328,10 @@ class ClientApplicationTests(NeoTestBase): ...@@ -331,12 +328,10 @@ class ClientApplicationTests(NeoTestBase):
}) })
app.pt = Mock({ 'getCellListForOID': [cell, ], }) app.pt = Mock({ 'getCellListForOID': [cell, ], })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
app.local_var.asked_object = -1
self.assertRaises(NEOStorageNotFoundError, app.loadBefore, oid, tid2) self.assertRaises(NEOStorageNotFoundError, app.loadBefore, oid, tid2)
self.checkAskObject(conn) self.checkAskObject(conn)
# no previous versions -> return None # no visible version -> NEOStorageNotFoundError
an_object = (1, oid, tid2, INVALID_SERIAL, 0, makeChecksum(''), '', an_object = (1, oid, INVALID_SERIAL, None, 0, 0, '', None)
None)
packet = Packets.AnswerObject(*an_object[1:]) packet = Packets.AnswerObject(*an_object[1:])
packet.setId(0) packet.setId(0)
conn = Mock({ conn = Mock({
...@@ -345,8 +340,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -345,8 +340,7 @@ class ClientApplicationTests(NeoTestBase):
}) })
app.cp = Mock({ 'getConnForCell' : conn}) app.cp = Mock({ 'getConnForCell' : conn})
app.local_var.asked_object = an_object[:-1] app.local_var.asked_object = an_object[:-1]
result = app.loadBefore(oid, tid1) self.assertRaises(NEOStorageError, app.loadBefore, oid, tid1)
self.assertEquals(result, None)
# object should not have been cached # object should not have been cached
self.assertFalse(oid in mq) self.assertFalse(oid in mq)
# as for loadSerial, the object is cached but should be loaded from db # as for loadSerial, the object is cached but should be loaded from db
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment