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
=== modified file 'tests/platform/windows/test_tools.py'
--- tests/platform/windows/test_tools.py 2012-04-09 20:07:05 +0000
+++ tests/platform/windows/test_tools.py 2012-04-24 20:51:20 +0000
@@ -29,6 +29,7 @@
29"""Tests for some tools for talking to the syncdaemon."""29"""Tests for some tools for talking to the syncdaemon."""
3030
31import sys31import sys
32import operator
3233
33from twisted.internet import defer34from twisted.internet import defer
34from twisted.trial.unittest import TestCase35from twisted.trial.unittest import TestCase
@@ -50,6 +51,7 @@
50 yield super(TestSyncDaemonTool, self).setUp()51 yield super(TestSyncDaemonTool, self).setUp()
51 self.patch(windows.UbuntuOneClient, "connect", lambda _: defer.Deferred())52 self.patch(windows.UbuntuOneClient, "connect", lambda _: defer.Deferred())
52 self.sdtool = windows.SyncDaemonToolProxy()53 self.sdtool = windows.SyncDaemonToolProxy()
54 self.calls = {}
5355
54 def test_call_after_connection(self):56 def test_call_after_connection(self):
55 """Test the _call_after_connection method."""57 """Test the _call_after_connection method."""
@@ -61,6 +63,31 @@
61 self.sdtool.connected.callback("got connected!")63 self.sdtool.connected.callback("got connected!")
62 self.assertEqual(len(collected_calls), 1)64 self.assertEqual(len(collected_calls), 1)
6365
66 def test_call_after_connection_connect(self):
67 """Test execute connect in _call_after_connection method."""
68 self.patch(self.sdtool.client, "is_connected", lambda: False)
69 my_connect = lambda *args, **kwargs: operator.setitem(
70 self.calls, "connect", (args, kwargs))
71 self.patch(self.sdtool.client, "connect", my_connect)
72 collected_calls = []
73 test_method = lambda *args: collected_calls.append(args)
74 test_method = self.sdtool._call_after_connection(test_method)
75 test_method(123)
76 self.assertIn("connect", self.calls)
77 self.assertEqual(self.calls["connect"], ((), {}))
78
79 def test_call_after_connection_not_connect(self):
80 """Test execute connect in _call_after_connection method."""
81 self.patch(self.sdtool.client, "is_connected", lambda: True)
82 my_connect = lambda *args, **kwargs: operator.setitem(
83 self.calls, "connect", (args, kwargs))
84 self.patch(self.sdtool.client, "connect", my_connect)
85 collected_calls = []
86 test_method = lambda *args: collected_calls.append(args)
87 test_method = self.sdtool._call_after_connection(test_method)
88 test_method(123)
89 self.assertNotIn("connect", self.calls)
90
64 def test_should_wrap(self):91 def test_should_wrap(self):
65 """Only some attributes should be wrapped."""92 """Only some attributes should be wrapped."""
66 test_function = "sample_function"93 test_function = "sample_function"
6794
=== modified file 'tests/syncdaemon/test_action_queue.py'
--- tests/syncdaemon/test_action_queue.py 2012-04-24 18:56:40 +0000
+++ tests/syncdaemon/test_action_queue.py 2012-04-24 20:51:20 +0000
@@ -1309,6 +1309,7 @@
1309 orig = self.action_queue.clientConnectionLost1309 orig = self.action_queue.clientConnectionLost
13101310
1311 d = defer.Deferred()1311 d = defer.Deferred()
1312
1312 def faked_connectionLost(*args, **kwargs):1313 def faked_connectionLost(*args, **kwargs):
1313 """Receive connection lost and check."""1314 """Receive connection lost and check."""
1314 orig(*args, **kwargs)1315 orig(*args, **kwargs)
13151316
=== modified file 'ubuntuone/platform/tools/windows.py'
--- ubuntuone/platform/tools/windows.py 2012-04-09 20:07:05 +0000
+++ ubuntuone/platform/tools/windows.py 2012-04-24 20:51:20 +0000
@@ -126,10 +126,12 @@
126126
127 def __init__(self, bus=None):127 def __init__(self, bus=None):
128 self.client = UbuntuOneClient()128 self.client = UbuntuOneClient()
129 self.connected = self.client.connect()129 self.connected = None
130130
131 def _call_after_connection(self, method):131 def _call_after_connection(self, method):
132 """Make sure Perspective Broker is connected before calling."""132 """Make sure Perspective Broker is connected before calling."""
133 if not self.client.is_connected():
134 self.connected = self.client.connect()
133135
134 @defer.inlineCallbacks136 @defer.inlineCallbacks
135 def call_after_connection_inner(*args, **kwargs):137 def call_after_connection_inner(*args, **kwargs):
136138
=== modified file 'ubuntuone/platform/windows/ipc_client.py'
--- ubuntuone/platform/windows/ipc_client.py 2012-04-09 20:07:05 +0000
+++ ubuntuone/platform/windows/ipc_client.py 2012-04-24 20:51:20 +0000
@@ -759,6 +759,10 @@
759 'Could not connect to the syncdaemon ipc.', e)759 'Could not connect to the syncdaemon ipc.', e)
760 # pylint: disable=W0702760 # pylint: disable=W0702
761761
762 def is_connected(self):
763 """Return if the client is connected."""
764 return (self.client is not None)
765
762 @defer.inlineCallbacks766 @defer.inlineCallbacks
763 def register_to_signals(self):767 def register_to_signals(self):
764 """Register the different clients to the signals."""768 """Register the different clients to the signals."""

Subscribers

People subscribed via source and target branches

to all changes: