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
1=== modified file 'magicicada/syncdaemon.py'
2--- magicicada/syncdaemon.py 2010-07-08 22:34:16 +0000
3+++ magicicada/syncdaemon.py 2010-07-21 23:21:00 +0000
4@@ -107,6 +107,7 @@
5 self.on_shares_to_me_changed_callback = NO_OP
6 self.on_shares_to_others_changed_callback = NO_OP
7 self.on_metadata_ready_callback = None # mandatory
8+ self.on_initial_data_ready_callback = NO_OP
9
10 # mq needs to be polled to know progress
11 self._mqcaller = None
12@@ -147,6 +148,10 @@
13 self.shares_to_me = yield self.dbus.get_shares_to_me()
14 self.shares_to_others = yield self.dbus.get_shares_to_others()
15
16+ # let frontend know that we have all the initial data
17+ logger.info("All initial data is ready")
18+ self.on_initial_data_ready_callback()
19+
20 @defer.inlineCallbacks
21 def on_sd_shares_changed(self):
22 """Shares changed, ask for new information."""
23
24=== modified file 'magicicada/tests/test_syncdaemon.py'
25--- magicicada/tests/test_syncdaemon.py 2010-07-08 22:37:44 +0000
26+++ magicicada/tests/test_syncdaemon.py 2010-07-21 23:21:00 +0000
27@@ -700,6 +700,13 @@
28 False, 'queues', 'connection')
29 self.assertTrue(self.called)
30
31+ @defer.inlineCallbacks
32+ def test_on_initial_data_ready(self):
33+ """Called when SD gets all the initial data."""
34+ self.flag_called(self.sd, 'on_initial_data_ready_callback')
35+ yield self.sd._get_initial_data()
36+ self.assertTrue(self.called)
37+
38
39 class TestLogs(unittest.TestCase):
40 """Test logging."""
41@@ -730,6 +737,7 @@
42 """Log the initial filling."""
43 yield self.sd._get_initial_data()
44 self.assertTrue(self.hdlr.check_info("Getting initial data"))
45+ self.assertTrue(self.hdlr.check_info("All initial data is ready"))
46
47 def test_start(self):
48 """Log the call to start."""

Subscribers

People subscribed via source and target branches