Merge lp:~dobey/ubuntuone-client/sdtool-q-3-0 into lp:ubuntuone-client/stable-3-0

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 1186
Merged at revision: 1186
Proposed branch: lp:~dobey/ubuntuone-client/sdtool-q-3-0
Merge into: lp:ubuntuone-client/stable-3-0
Diff against target: 96 lines (+35/-1)
4 files modified
tests/platform/windows/test_tools.py (+27/-0)
tests/syncdaemon/test_action_queue.py (+1/-0)
ubuntuone/platform/tools/windows.py (+3/-1)
ubuntuone/platform/windows/ipc_client.py (+4/-0)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/sdtool-q-3-0
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Review via email: mp+103376@code.launchpad.net

Commit message

- Avoid creating SyncDaemonTool if is not already running and the user wants to close it. (LP: #907479).

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) :
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_tools.py'
2--- tests/platform/windows/test_tools.py 2012-04-09 20:07:05 +0000
3+++ tests/platform/windows/test_tools.py 2012-04-24 20:51:20 +0000
4@@ -29,6 +29,7 @@
5 """Tests for some tools for talking to the syncdaemon."""
6
7 import sys
8+import operator
9
10 from twisted.internet import defer
11 from twisted.trial.unittest import TestCase
12@@ -50,6 +51,7 @@
13 yield super(TestSyncDaemonTool, self).setUp()
14 self.patch(windows.UbuntuOneClient, "connect", lambda _: defer.Deferred())
15 self.sdtool = windows.SyncDaemonToolProxy()
16+ self.calls = {}
17
18 def test_call_after_connection(self):
19 """Test the _call_after_connection method."""
20@@ -61,6 +63,31 @@
21 self.sdtool.connected.callback("got connected!")
22 self.assertEqual(len(collected_calls), 1)
23
24+ def test_call_after_connection_connect(self):
25+ """Test execute connect in _call_after_connection method."""
26+ self.patch(self.sdtool.client, "is_connected", lambda: False)
27+ my_connect = lambda *args, **kwargs: operator.setitem(
28+ self.calls, "connect", (args, kwargs))
29+ self.patch(self.sdtool.client, "connect", my_connect)
30+ collected_calls = []
31+ test_method = lambda *args: collected_calls.append(args)
32+ test_method = self.sdtool._call_after_connection(test_method)
33+ test_method(123)
34+ self.assertIn("connect", self.calls)
35+ self.assertEqual(self.calls["connect"], ((), {}))
36+
37+ def test_call_after_connection_not_connect(self):
38+ """Test execute connect in _call_after_connection method."""
39+ self.patch(self.sdtool.client, "is_connected", lambda: True)
40+ my_connect = lambda *args, **kwargs: operator.setitem(
41+ self.calls, "connect", (args, kwargs))
42+ self.patch(self.sdtool.client, "connect", my_connect)
43+ collected_calls = []
44+ test_method = lambda *args: collected_calls.append(args)
45+ test_method = self.sdtool._call_after_connection(test_method)
46+ test_method(123)
47+ self.assertNotIn("connect", self.calls)
48+
49 def test_should_wrap(self):
50 """Only some attributes should be wrapped."""
51 test_function = "sample_function"
52
53=== modified file 'tests/syncdaemon/test_action_queue.py'
54--- tests/syncdaemon/test_action_queue.py 2012-04-24 18:56:40 +0000
55+++ tests/syncdaemon/test_action_queue.py 2012-04-24 20:51:20 +0000
56@@ -1309,6 +1309,7 @@
57 orig = self.action_queue.clientConnectionLost
58
59 d = defer.Deferred()
60+
61 def faked_connectionLost(*args, **kwargs):
62 """Receive connection lost and check."""
63 orig(*args, **kwargs)
64
65=== modified file 'ubuntuone/platform/tools/windows.py'
66--- ubuntuone/platform/tools/windows.py 2012-04-09 20:07:05 +0000
67+++ ubuntuone/platform/tools/windows.py 2012-04-24 20:51:20 +0000
68@@ -126,10 +126,12 @@
69
70 def __init__(self, bus=None):
71 self.client = UbuntuOneClient()
72- self.connected = self.client.connect()
73+ self.connected = None
74
75 def _call_after_connection(self, method):
76 """Make sure Perspective Broker is connected before calling."""
77+ if not self.client.is_connected():
78+ self.connected = self.client.connect()
79
80 @defer.inlineCallbacks
81 def call_after_connection_inner(*args, **kwargs):
82
83=== modified file 'ubuntuone/platform/windows/ipc_client.py'
84--- ubuntuone/platform/windows/ipc_client.py 2012-04-09 20:07:05 +0000
85+++ ubuntuone/platform/windows/ipc_client.py 2012-04-24 20:51:20 +0000
86@@ -759,6 +759,10 @@
87 'Could not connect to the syncdaemon ipc.', e)
88 # pylint: disable=W0702
89
90+ def is_connected(self):
91+ """Return if the client is connected."""
92+ return (self.client is not None)
93+
94 @defer.inlineCallbacks
95 def register_to_signals(self):
96 """Register the different clients to the signals."""

Subscribers

People subscribed via source and target branches

to all changes: