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):
# True when current_partition is replicated, or we don't know yet if
# 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_connection = None
waiting_for_unfinished_tids = None
waiting_for_unfinished_tids = False
unfinished_tid_list = None
replication_done = None
replication_done = True
def __init__(self, app):
self.app = app
self.new_partition_dict = {}
self.critical_tid_dict = {}
self.partition_dict = {}
self.task_list = []
self.task_dict = {}
def populate(self):
"""
......
......@@ -44,40 +44,32 @@ class StorageReplicatorTests(NeoUnitTestBase):
),
})
replicator = Replicator(app)
assert replicator.new_partition_dict is None, \
replicator.new_partition_dict
assert replicator.critical_tid_dict is None, \
replicator.critical_tid_dict
assert replicator.partition_dict is None, replicator.partition_dict
self.assertEqual(replicator.new_partition_dict, {})
replicator.replication_done = False
replicator.populate()
self.assertEqual(len(replicator.new_partition_dict), 1)
partition = replicator.new_partition_dict[0]
self.assertEqual(partition.getRID(), 0)
self.assertEqual(partition.getCriticalTID(), None)
self.assertEqual(replicator.critical_tid_dict, {})
self.assertEqual(replicator.partition_dict, {})
self.assertTrue(replicator.replication_done)
def test_reset(self):
replicator = Replicator(None)
assert replicator.task_list is None, replicator.task_list
assert replicator.task_dict is None, replicator.task_dict
assert replicator.current_partition is None, \
replicator.current_partition
assert replicator.current_connection is None, \
replicator.current_connection
assert replicator.waiting_for_unfinished_tids is None, \
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.task_list = ['foo']
replicator.task_dict = {'foo': 'bar'}
replicator.current_partition = 'foo'
replicator.current_connection = 'foo'
replicator.waiting_for_unfinished_tids = 'foo'
replicator.unfinished_tid_list = ['foo']
replicator.replication_done = 'foo'
replicator.reset()
self.assertEqual(replicator.task_list, [])
self.assertEqual(replicator.task_dict, {})
self.assertEqual(replicator.current_partition, 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.replication_done, True)
self.assertTrue(replicator.replication_done)
def test_setCriticalTID(self):
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