Commit 4741e38e authored by Julien Muchembled's avatar Julien Muchembled

Make unit tests honor NEO_TESTS_ADAPTER instead of always testing MySQL

parent ad01f379
...@@ -188,16 +188,22 @@ class NeoUnitTestBase(NeoTestBase): ...@@ -188,16 +188,22 @@ class NeoUnitTestBase(NeoTestBase):
assert index >= 0 and index <= 9 assert index >= 0 and index <= 9
masters = [(buildUrlFromString(self.local_ip), masters = [(buildUrlFromString(self.local_ip),
10010 + i) for i in xrange(master_number)] 10010 + i) for i in xrange(master_number)]
database = '%s@%s%s' % (DB_USER, prefix, index) adapter = os.getenv('NEO_TESTS_ADAPTER', 'MySQL')
if adapter == 'MySQL':
db = '%s@%s%s' % (DB_USER, prefix, index)
elif adapter == 'SQLite':
db = os.path.join(getTempDirectory(), 'test_neo%s.sqlite' % index)
else:
assert False, adapter
return Mock({ return Mock({
'getCluster': cluster, 'getCluster': cluster,
'getBind': (masters[0], 10020 + index), 'getBind': (masters[0], 10020 + index),
'getMasters': (masters, getAddressType(( 'getMasters': (masters, getAddressType((
self.local_ip, 0))), self.local_ip, 0))),
'getDatabase': database, 'getDatabase': db,
'getUUID': uuid, 'getUUID': uuid,
'getReset': False, 'getReset': False,
'getAdapter': 'MySQL', 'getAdapter': adapter,
}) })
def getNewUUID(self, node_type): def getNewUUID(self, node_type):
......
...@@ -71,7 +71,7 @@ class StorageInitializationHandlerTests(NeoUnitTestBase): ...@@ -71,7 +71,7 @@ class StorageInitializationHandlerTests(NeoUnitTestBase):
self.app.nm.createStorage(uuid=node_1) self.app.nm.createStorage(uuid=node_1)
self.app.nm.createStorage(uuid=node_2) self.app.nm.createStorage(uuid=node_2)
self.app.nm.createStorage(uuid=node_3) self.app.nm.createStorage(uuid=node_3)
self.assertEqual(self.app.dm.getPartitionTable(), ()) self.assertFalse(list(self.app.dm.getPartitionTable()))
row_list = [(0, ((node_1, CellStates.UP_TO_DATE), (node_2, CellStates.UP_TO_DATE))), row_list = [(0, ((node_1, CellStates.UP_TO_DATE), (node_2, CellStates.UP_TO_DATE))),
(1, ((node_3, CellStates.UP_TO_DATE), (node_1, CellStates.UP_TO_DATE))), (1, ((node_3, CellStates.UP_TO_DATE), (node_1, CellStates.UP_TO_DATE))),
(2, ((node_2, CellStates.UP_TO_DATE), (node_3, CellStates.UP_TO_DATE)))] (2, ((node_2, CellStates.UP_TO_DATE), (node_3, CellStates.UP_TO_DATE)))]
...@@ -80,7 +80,7 @@ class StorageInitializationHandlerTests(NeoUnitTestBase): ...@@ -80,7 +80,7 @@ class StorageInitializationHandlerTests(NeoUnitTestBase):
self.verification.answerPartitionTable(conn, 2, row_list) self.verification.answerPartitionTable(conn, 2, row_list)
self.assertTrue(self.app.pt.filled()) self.assertTrue(self.app.pt.filled())
self.assertEqual(self.app.pt.getID(), 2) self.assertEqual(self.app.pt.getID(), 2)
self.assertNotEqual(self.app.dm.getPartitionTable(), []) self.assertTrue(list(self.app.dm.getPartitionTable()))
if __name__ == "__main__": if __name__ == "__main__":
......
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