Merge lp:~alecu/ubuntuone-client/status-changed into lp:ubuntuone-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1058
Merged at revision: 1054
Proposed branch: lp:~alecu/ubuntuone-client/status-changed
Merge into: lp:ubuntuone-client
Diff against target: 130 lines (+30/-6)
5 files modified
tests/platform/windows/test_ipc.py (+9/-3)
tests/platform/windows/test_tools.py (+11/-0)
ubuntuone/platform/windows/ipc.py (+5/-3)
ubuntuone/platform/windows/tools.py (+4/-0)
ubuntuone/syncdaemon/interaction_interfaces.py (+1/-0)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/status-changed
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+68116@code.launchpad.net

Commit message

Connect the signal for status changed (LP: #806655)

Description of the change

Connect the signal for status changed (LP: #806655)

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

Looks great!

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/windows/test_ipc.py'
2--- tests/platform/windows/test_ipc.py 2011-07-13 19:55:31 +0000
3+++ tests/platform/windows/test_ipc.py 2011-07-15 17:38:24 +0000
4@@ -3049,7 +3049,8 @@
5 self.action_queue = self.mocker.mock()
6 self.fs_manager = self.mocker.mock()
7 self.volume_manager = self.mocker.mock()
8- self.ipc_root = IPCRoot(self.main)
9+ self.ipc_interface = self.mocker.mock()
10+ self.ipc_root = IPCRoot(self.ipc_interface, self.main)
11 self.server_factory = SaveProtocolServerFactory(self.ipc_root)
12 self.listener = ipc_server_listen(self.server_factory)
13 self.client_factory = PBClientFactory()
14@@ -3235,9 +3236,10 @@
15 class FakeIPCRoot(object, ipc.Root):
16 """A Fake IPC Root."""
17
18- def __init__(self, *args, **kwargs):
19+ def __init__(self, ipc_interface, *args, **kwargs):
20 """Initialize this fake instance."""
21- # This empty method is needed to override the default constructor
22+ # just save the ipc_interface
23+ self.ipc_interface = ipc_interface
24
25
26 class RandomException(Exception):
27@@ -3316,6 +3318,10 @@
28
29 cmt_class = FakeCredentialsManagementTool
30
31+ def test_ipc_root_created_ok(self):
32+ """The IPCRoot is passed the IPCInterface."""
33+ self.assertEqual(self.ipc.root.ipc_interface, self.ipc)
34+
35 @defer.inlineCallbacks
36 def test_connect(self):
37 """Test the connect method."""
38
39=== modified file 'tests/platform/windows/test_tools.py'
40--- tests/platform/windows/test_tools.py 2011-07-06 16:32:37 +0000
41+++ tests/platform/windows/test_tools.py 2011-07-15 17:38:24 +0000
42@@ -137,6 +137,8 @@
43 self.server_factory = SaveProtocolServerFactory(self.syncdaemon_root)
44 # pylint: disable=E1101
45 self.patch(ipc, "HOST_PORT", TEST_TOOLS_HOST_PORT)
46+ self.patch(ipc.ActivationClient, "get_active_port",
47+ lambda _: defer.succeed(TEST_TOOLS_HOST_PORT[1]))
48 self.listener = ipc_server_listen(self.server_factory)
49 self.sdtool = SyncDaemonTool()
50
51@@ -1099,6 +1101,15 @@
52 # pylint: enable=E1101
53 return d
54
55+ @defer.inlineCallbacks
56+ def test_set_status_changed_handler(self):
57+ """The status handler is changed."""
58+ test_handler = object()
59+ sdtool = yield self._connect()
60+ yield sdtool.set_status_changed_handler(test_handler)
61+ self.assertEqual(sdtool.client.status.on_status_changed_cb,
62+ test_handler)
63+
64 def test_start(self):
65 """Test that we can indeed start the process."""
66 cmd = 'notepad'
67
68=== modified file 'ubuntuone/platform/windows/ipc.py'
69--- ubuntuone/platform/windows/ipc.py 2011-07-13 19:55:31 +0000
70+++ ubuntuone/platform/windows/ipc.py 2011-07-15 17:38:24 +0000
71@@ -157,6 +157,7 @@
72
73 def emit_signal(self, signal_name, *args, **kwargs):
74 """Emit the given signal to the clients."""
75+ logger.debug("emitting %r to all connected clients.", signal_name)
76 for current_client in self.clients:
77 try:
78 d = current_client.callRemote(signal_name, *args, **kwargs)
79@@ -956,7 +957,8 @@
80 'get_folders',
81 'get_public_files']
82
83- def __init__(self, main, send_events=False, all_events=AllEventsSender):
84+ def __init__(self, ipc_interface, main, send_events=False,
85+ all_events=AllEventsSender):
86 """Create a new instance that will expose the objects."""
87 super(IPCRoot, self).__init__()
88 self.main = main
89@@ -975,7 +977,7 @@
90 self.all_events_sender = all_events(self.events)
91 self.event_queue.subscribe(self.all_events_sender)
92
93- self.sync = SyncDaemon(self, self.main, self.volume_manager,
94+ self.sync = SyncDaemon(ipc_interface, self.main, self.volume_manager,
95 self.action_queue)
96 self.fs = FileSystem(self.fs_manager, self.action_queue)
97 self.shares = Shares(self.fs_manager, self.volume_manager)
98@@ -1027,7 +1029,7 @@
99 specified bus.
100 """
101 super(IPCInterface, self).__init__()
102- self.root = IPCRoot(main, send_events)
103+ self.root = IPCRoot(self, main, send_events)
104 self.listener = ipc_server_listen(PBServerFactory(self.root))
105 self.main = main
106
107
108=== modified file 'ubuntuone/platform/windows/tools.py'
109--- ubuntuone/platform/windows/tools.py 2011-07-12 04:37:51 +0000
110+++ ubuntuone/platform/windows/tools.py 2011-07-15 17:38:24 +0000
111@@ -566,3 +566,7 @@
112 """Return the shares link directory."""
113 return self.client.sync_daemon.get_sharesdir_link()
114
115+ def set_status_changed_handler(self, handler):
116+ """Set the status changed handler."""
117+ self.client.status.on_status_changed_cb = handler
118+ return defer.succeed(None)
119
120=== modified file 'ubuntuone/syncdaemon/interaction_interfaces.py'
121--- ubuntuone/syncdaemon/interaction_interfaces.py 2011-06-28 15:55:19 +0000
122+++ ubuntuone/syncdaemon/interaction_interfaces.py 2011-07-15 17:38:24 +0000
123@@ -929,6 +929,7 @@
124
125 def handle_SYS_STATE_CHANGED(self, state):
126 """Handle SYS_STATE_CHANGED."""
127+ logger.debug('emitting state changed: %r', state)
128 self.interface.status.emit_status_changed(state)
129
130 def handle_SV_FREE_SPACE(self, share_id, free_bytes):

Subscribers

People subscribed via source and target branches