Commit ff0d9d70 authored by Vincent Pelletier's avatar Vincent Pelletier

Use more sensible default values.

Also, improve test (try to break code in tests, don't test unneeded
properties).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2433 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 8a599ee2
...@@ -140,19 +140,19 @@ class Replicator(object): ...@@ -140,19 +140,19 @@ class Replicator(object):
# True when current_partition is replicated, or we don't know yet if # True when current_partition is replicated, or we don't know yet if
# there is something to replicate # there is something to replicate
new_partition_dict = None
critical_tid_dict = None
partition_dict = None
task_list = None
task_dict = None
current_partition = None current_partition = None
current_connection = None current_connection = None
waiting_for_unfinished_tids = None waiting_for_unfinished_tids = False
unfinished_tid_list = None unfinished_tid_list = None
replication_done = None replication_done = True
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
self.new_partition_dict = {}
self.critical_tid_dict = {}
self.partition_dict = {}
self.task_list = []
self.task_dict = {}
def populate(self): def populate(self):
""" """
......
...@@ -44,40 +44,32 @@ class StorageReplicatorTests(NeoUnitTestBase): ...@@ -44,40 +44,32 @@ class StorageReplicatorTests(NeoUnitTestBase):
), ),
}) })
replicator = Replicator(app) replicator = Replicator(app)
assert replicator.new_partition_dict is None, \ self.assertEqual(replicator.new_partition_dict, {})
replicator.new_partition_dict replicator.replication_done = False
assert replicator.critical_tid_dict is None, \
replicator.critical_tid_dict
assert replicator.partition_dict is None, replicator.partition_dict
replicator.populate() replicator.populate()
self.assertEqual(len(replicator.new_partition_dict), 1) self.assertEqual(len(replicator.new_partition_dict), 1)
partition = replicator.new_partition_dict[0] partition = replicator.new_partition_dict[0]
self.assertEqual(partition.getRID(), 0) self.assertEqual(partition.getRID(), 0)
self.assertEqual(partition.getCriticalTID(), None) self.assertEqual(partition.getCriticalTID(), None)
self.assertEqual(replicator.critical_tid_dict, {}) self.assertTrue(replicator.replication_done)
self.assertEqual(replicator.partition_dict, {})
def test_reset(self): def test_reset(self):
replicator = Replicator(None) replicator = Replicator(None)
assert replicator.task_list is None, replicator.task_list replicator.task_list = ['foo']
assert replicator.task_dict is None, replicator.task_dict replicator.task_dict = {'foo': 'bar'}
assert replicator.current_partition is None, \ replicator.current_partition = 'foo'
replicator.current_partition replicator.current_connection = 'foo'
assert replicator.current_connection is None, \ replicator.waiting_for_unfinished_tids = 'foo'
replicator.current_connection replicator.unfinished_tid_list = ['foo']
assert replicator.waiting_for_unfinished_tids is None, \ replicator.replication_done = 'foo'
replicator.waiting_for_unfinished_tids
assert replicator.unfinished_tid_list is None, \
replicator.unfinished_tid_list
assert replicator.replication_done is None, replicator.replication_done
replicator.reset() replicator.reset()
self.assertEqual(replicator.task_list, []) self.assertEqual(replicator.task_list, [])
self.assertEqual(replicator.task_dict, {}) self.assertEqual(replicator.task_dict, {})
self.assertEqual(replicator.current_partition, None) self.assertEqual(replicator.current_partition, None)
self.assertEqual(replicator.current_connection, None) self.assertEqual(replicator.current_connection, None)
self.assertEqual(replicator.waiting_for_unfinished_tids, False) self.assertFalse(replicator.waiting_for_unfinished_tids)
self.assertEqual(replicator.unfinished_tid_list, None) self.assertEqual(replicator.unfinished_tid_list, None)
self.assertEqual(replicator.replication_done, True) self.assertTrue(replicator.replication_done)
def test_setCriticalTID(self): def test_setCriticalTID(self):
replicator = Replicator(None) replicator = Replicator(None)
......
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