Commit 731d875d authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fix connection tests (use getNewUUID from the test instance instead of global)


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1284 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 4d988c1c
...@@ -163,7 +163,7 @@ class ConnectionTests(NeoTestBase): ...@@ -163,7 +163,7 @@ class ConnectionTests(NeoTestBase):
# test uuid # test uuid
self.assertEqual(bc.uuid, None) self.assertEqual(bc.uuid, None)
self.assertEqual(bc.getUUID(), None) self.assertEqual(bc.getUUID(), None)
uuid = getNewUUID() uuid = self.getNewUUID()
bc.setUUID(uuid) bc.setUUID(uuid)
self.assertEqual(bc.getUUID(), uuid) self.assertEqual(bc.getUUID(), uuid)
# test next id # test next id
...@@ -181,7 +181,7 @@ class ConnectionTests(NeoTestBase): ...@@ -181,7 +181,7 @@ class ConnectionTests(NeoTestBase):
# test abort # test abort
bc.abort() bc.abort()
self.assertEqual(bc.aborted, True) self.assertEqual(bc.aborted, True)
self.assertRaises(NotImplementedError, bc.isServer) self.assertFalse(bc.isServer())
def test_04_Connection_pending(self): def test_04_Connection_pending(self):
em = Mock() em = Mock()
...@@ -498,11 +498,16 @@ class ConnectionTests(NeoTestBase): ...@@ -498,11 +498,16 @@ class ConnectionTests(NeoTestBase):
self.assertEqual(len(bc.event_dict), 0) self.assertEqual(len(bc.event_dict), 0)
# give some data to analyse # give some data to analyse
master_list = ((("127.0.0.1", 2135), getNewUUID()), (("127.0.0.1", 2135), getNewUUID()), master_list = (
(("127.0.0.1", 2235), getNewUUID()), (("127.0.0.1", 2134), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2335), getNewUUID()),(("127.0.0.1", 2133), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2435), getNewUUID()),(("127.0.0.1", 2132), getNewUUID())) (("127.0.0.1", 2235), self.getNewUUID()),
p = protocol.answerPrimaryMaster(getNewUUID(), master_list) (("127.0.0.1", 2134), self.getNewUUID()),
(("127.0.0.1", 2335), self.getNewUUID()),
(("127.0.0.1", 2133), self.getNewUUID()),
(("127.0.0.1", 2435), self.getNewUUID()),
(("127.0.0.1", 2132), self.getNewUUID()))
p = protocol.answerPrimaryMaster(self.getNewUUID(), master_list)
p.setId(1) p.setId(1)
data = p.encode() data = p.encode()
bc.read_buf += data bc.read_buf += data
...@@ -526,20 +531,30 @@ class ConnectionTests(NeoTestBase): ...@@ -526,20 +531,30 @@ class ConnectionTests(NeoTestBase):
connector=connector, addr=("127.0.0.7", 93413)) connector=connector, addr=("127.0.0.7", 93413))
bc._queue = Mock() bc._queue = Mock()
# packet 1 # packet 1
master_list = ((("127.0.0.1", 2135), getNewUUID()), (("127.0.0.1", 2135), getNewUUID()), master_list = (
(("127.0.0.1", 2235), getNewUUID()), (("127.0.0.1", 2134), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2335), getNewUUID()),(("127.0.0.1", 2133), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2435), getNewUUID()),(("127.0.0.1", 2132), getNewUUID())) (("127.0.0.1", 2235), self.getNewUUID()),
p1 = protocol.answerPrimaryMaster(getNewUUID(), master_list) (("127.0.0.1", 2134), self.getNewUUID()),
(("127.0.0.1", 2335), self.getNewUUID()),
(("127.0.0.1", 2133), self.getNewUUID()),
(("127.0.0.1", 2435), self.getNewUUID()),
(("127.0.0.1", 2132), self.getNewUUID()))
p1 = protocol.answerPrimaryMaster(self.getNewUUID(), master_list)
p1.setId(1) p1.setId(1)
data = p1.encode() data = p1.encode()
bc.read_buf += data bc.read_buf += data
# packet 2 # packet 2
master_list = ((("127.0.0.1", 2135), getNewUUID()), (("127.0.0.1", 2135), getNewUUID()), master_list = (
(("127.0.0.1", 2235), getNewUUID()), (("127.0.0.1", 2134), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2335), getNewUUID()),(("127.0.0.1", 2133), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2435), getNewUUID()),(("127.0.0.1", 2132), getNewUUID())) (("127.0.0.1", 2235), self.getNewUUID()),
p2 = protocol.answerPrimaryMaster( getNewUUID(), master_list) (("127.0.0.1", 2134), self.getNewUUID()),
(("127.0.0.1", 2335), self.getNewUUID()),
(("127.0.0.1", 2133), self.getNewUUID()),
(("127.0.0.1", 2435), self.getNewUUID()),
(("127.0.0.1", 2132), self.getNewUUID()))
p2 = protocol.answerPrimaryMaster( self.getNewUUID(), master_list)
p2.setId(2) p2.setId(2)
data = p2.encode() data = p2.encode()
bc.read_buf += data bc.read_buf += data
...@@ -585,11 +600,16 @@ class ConnectionTests(NeoTestBase): ...@@ -585,11 +600,16 @@ class ConnectionTests(NeoTestBase):
connector=connector, addr=("127.0.0.7", 93413)) connector=connector, addr=("127.0.0.7", 93413))
bc._queue = Mock() bc._queue = Mock()
master_list = ((("127.0.0.1", 2135), getNewUUID()), (("127.0.0.1", 2135), getNewUUID()), master_list = (
(("127.0.0.1", 2235), getNewUUID()), (("127.0.0.1", 2134), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2335), getNewUUID()),(("127.0.0.1", 2133), getNewUUID()), (("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2435), getNewUUID()),(("127.0.0.1", 2132), getNewUUID())) (("127.0.0.1", 2235), self.getNewUUID()),
p = protocol.answerPrimaryMaster(getNewUUID(), master_list) (("127.0.0.1", 2134), self.getNewUUID()),
(("127.0.0.1", 2335), self.getNewUUID()),
(("127.0.0.1", 2133), self.getNewUUID()),
(("127.0.0.1", 2435), self.getNewUUID()),
(("127.0.0.1", 2132), self.getNewUUID()))
p = protocol.answerPrimaryMaster(self.getNewUUID(), master_list)
p.setId(1) p.setId(1)
data = p.encode() data = p.encode()
bc.read_buf += data bc.read_buf += data
...@@ -711,11 +731,15 @@ class ConnectionTests(NeoTestBase): ...@@ -711,11 +731,15 @@ class ConnectionTests(NeoTestBase):
handler = Mock() handler = Mock()
# patch receive method to return data # patch receive method to return data
def receive(self): def receive(self):
master_list = ((("127.0.0.1", 2135), getNewUUID()), (("127.0.0.1", 2136), getNewUUID()), master_list = ((("127.0.0.1", 2135), self.getNewUUID()),
(("127.0.0.1", 2235), getNewUUID()), (("127.0.0.1", 2134), getNewUUID()), (("127.0.0.1", 2136), self.getNewUUID()),
(("127.0.0.1", 2335), getNewUUID()),(("127.0.0.1", 2133), getNewUUID()), (("127.0.0.1", 2235), self.getNewUUID()),
(("127.0.0.1", 2435), getNewUUID()),(("127.0.0.1", 2132), getNewUUID())) (("127.0.0.1", 2134), self.getNewUUID()),
uuid = getNewUUID() (("127.0.0.1", 2335), self.getNewUUID()),
(("127.0.0.1", 2133), self.getNewUUID()),
(("127.0.0.1", 2435), self.getNewUUID()),
(("127.0.0.1", 2132), self.getNewUUID()))
uuid = self.getNewUUID()
p = protocol.answerPrimaryMaster(uuid, master_list) p = protocol.answerPrimaryMaster(uuid, master_list)
p.setId(1) p.setId(1)
data = p.encode() data = p.encode()
...@@ -969,7 +993,7 @@ class ConnectionTests(NeoTestBase): ...@@ -969,7 +993,7 @@ class ConnectionTests(NeoTestBase):
# test uuid # test uuid
self.assertEqual(bc.uuid, None) self.assertEqual(bc.uuid, None)
self.assertEqual(bc.getUUID(), None) self.assertEqual(bc.getUUID(), None)
uuid = getNewUUID() uuid = self.getNewUUID()
bc.setUUID(uuid) bc.setUUID(uuid)
self.assertEqual(bc.getUUID(), uuid) self.assertEqual(bc.getUUID(), uuid)
# test next id # test next id
...@@ -1092,7 +1116,7 @@ class ConnectionTests(NeoTestBase): ...@@ -1092,7 +1116,7 @@ class ConnectionTests(NeoTestBase):
# test uuid # test uuid
self.assertEqual(bc.uuid, None) self.assertEqual(bc.uuid, None)
self.assertEqual(bc.getUUID(), None) self.assertEqual(bc.getUUID(), None)
uuid = getNewUUID() uuid = self.getNewUUID()
bc.setUUID(uuid) bc.setUUID(uuid)
self.assertEqual(bc.getUUID(), uuid) self.assertEqual(bc.getUUID(), uuid)
# test next id # test next id
......
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