Merge lp:~facundo/magicicada-gui/alert-when-initial-data into lp:magicicada-gui

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 62
Merged at revision: 63
Proposed branch: lp:~facundo/magicicada-gui/alert-when-initial-data
Merge into: lp:magicicada-gui
Diff against target: 48 lines (+13/-0)
2 files modified
magicicada/syncdaemon.py (+5/-0)
magicicada/tests/test_syncdaemon.py (+8/-0)
To merge this branch: bzr merge lp:~facundo/magicicada-gui/alert-when-initial-data
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+30596@code.launchpad.net

Description of the change

When the SD has all the initial data, call the callback.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Awesome!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'magicicada/syncdaemon.py'
--- magicicada/syncdaemon.py 2010-07-08 22:34:16 +0000
+++ magicicada/syncdaemon.py 2010-07-21 23:21:00 +0000
@@ -107,6 +107,7 @@
107 self.on_shares_to_me_changed_callback = NO_OP107 self.on_shares_to_me_changed_callback = NO_OP
108 self.on_shares_to_others_changed_callback = NO_OP108 self.on_shares_to_others_changed_callback = NO_OP
109 self.on_metadata_ready_callback = None # mandatory109 self.on_metadata_ready_callback = None # mandatory
110 self.on_initial_data_ready_callback = NO_OP
110111
111 # mq needs to be polled to know progress112 # mq needs to be polled to know progress
112 self._mqcaller = None113 self._mqcaller = None
@@ -147,6 +148,10 @@
147 self.shares_to_me = yield self.dbus.get_shares_to_me()148 self.shares_to_me = yield self.dbus.get_shares_to_me()
148 self.shares_to_others = yield self.dbus.get_shares_to_others()149 self.shares_to_others = yield self.dbus.get_shares_to_others()
149150
151 # let frontend know that we have all the initial data
152 logger.info("All initial data is ready")
153 self.on_initial_data_ready_callback()
154
150 @defer.inlineCallbacks155 @defer.inlineCallbacks
151 def on_sd_shares_changed(self):156 def on_sd_shares_changed(self):
152 """Shares changed, ask for new information."""157 """Shares changed, ask for new information."""
153158
=== modified file 'magicicada/tests/test_syncdaemon.py'
--- magicicada/tests/test_syncdaemon.py 2010-07-08 22:37:44 +0000
+++ magicicada/tests/test_syncdaemon.py 2010-07-21 23:21:00 +0000
@@ -700,6 +700,13 @@
700 False, 'queues', 'connection')700 False, 'queues', 'connection')
701 self.assertTrue(self.called)701 self.assertTrue(self.called)
702702
703 @defer.inlineCallbacks
704 def test_on_initial_data_ready(self):
705 """Called when SD gets all the initial data."""
706 self.flag_called(self.sd, 'on_initial_data_ready_callback')
707 yield self.sd._get_initial_data()
708 self.assertTrue(self.called)
709
703710
704class TestLogs(unittest.TestCase):711class TestLogs(unittest.TestCase):
705 """Test logging."""712 """Test logging."""
@@ -730,6 +737,7 @@
730 """Log the initial filling."""737 """Log the initial filling."""
731 yield self.sd._get_initial_data()738 yield self.sd._get_initial_data()
732 self.assertTrue(self.hdlr.check_info("Getting initial data"))739 self.assertTrue(self.hdlr.check_info("Getting initial data"))
740 self.assertTrue(self.hdlr.check_info("All initial data is ready"))
733741
734 def test_start(self):742 def test_start(self):
735 """Log the call to start."""743 """Log the call to start."""

Subscribers

People subscribed via source and target branches