Merge lp:~nataliabidart/ubuntuone-client/disable-properly into lp:ubuntuone-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 933
Merged at revision: 932
Proposed branch: lp:~nataliabidart/ubuntuone-client/disable-properly
Merge into: lp:ubuntuone-client
Diff against target: 115 lines (+74/-5)
2 files modified
tests/platform/linux/test_tools.py (+64/-0)
ubuntuone/platform/linux/tools.py (+10/-5)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-client/disable-properly
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Facundo Batista (community) Approve
Review via email: mp+55994@code.launchpad.net

Commit message

- When requesting disabling the service, also quit the service (LP: #744980).

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

Like it!

review: Approve
932. By Natalia Bidart

Merged trunk in.

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve
933. By Natalia Bidart

Improving debug messages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/linux/test_tools.py'
2--- tests/platform/linux/test_tools.py 2011-02-28 16:24:21 +0000
3+++ tests/platform/linux/test_tools.py 2011-04-04 15:36:35 +0000
4@@ -520,6 +520,70 @@
5 self.assertFalse(enabled)
6
7 @defer.inlineCallbacks
8+ def test_is_files_sync_enabled(self):
9+ """Test for is_files_sync_enabled."""
10+ yield self.tool.enable_files_sync(False)
11+ enabled = yield self.tool.is_files_sync_enabled()
12+ self.assertFalse(enabled)
13+
14+ yield self.tool.enable_files_sync(True)
15+ enabled = yield self.tool.is_files_sync_enabled()
16+ self.assertTrue(enabled)
17+
18+ @defer.inlineCallbacks
19+ def test_enable_files_sync(self):
20+ """Test for enable_files_sync."""
21+ yield self.tool.enable_files_sync(True)
22+ enabled = yield self.tool.is_files_sync_enabled()
23+ self.assertTrue(enabled)
24+
25+ @defer.inlineCallbacks
26+ def test_enable_files_sync_when_disabled(self):
27+ """Test for enable_files_sync."""
28+ called = []
29+ self.patch(self.tool, 'start', lambda: called.append('start'))
30+ yield self.tool.enable_files_sync(False)
31+ # be sure file sync is disabled
32+
33+ yield self.tool.enable_files_sync(True)
34+ # assert that the services was started
35+ self.assertEqual(called, ['start'])
36+
37+ config = tools.get_user_config()
38+ self.assertEqual(True, config.get_files_sync_enabled())
39+
40+ @defer.inlineCallbacks
41+ def test_disable_files_sync(self):
42+ """Test for enable_files_sync."""
43+ yield self.tool.enable_files_sync(False)
44+ enabled = yield self.tool.is_files_sync_enabled()
45+ self.assertFalse(enabled)
46+
47+ @defer.inlineCallbacks
48+ def test_disable_files_sync_when_disabled(self):
49+ """Test for enable_files_sync."""
50+ yield self.tool.enable_files_sync(False)
51+
52+ yield self.tool.enable_files_sync(False)
53+ enabled = yield self.tool.is_files_sync_enabled()
54+ self.assertFalse(enabled)
55+
56+ @defer.inlineCallbacks
57+ def test_disable_files_sync_when_enabled(self):
58+ """Test for enable_files_sync."""
59+ called = []
60+ self.patch(self.tool, 'quit', lambda: called.append('quit'))
61+ yield self.tool.enable_files_sync(True)
62+ # be sure file sync is enabled
63+
64+ yield self.tool.enable_files_sync(False)
65+ # assert that the services was stopped
66+ self.assertEqual(called, ['quit'])
67+
68+ config = tools.get_user_config()
69+ self.assertEqual(False, config.get_files_sync_enabled())
70+
71+ @defer.inlineCallbacks
72 def test_refresh_volumes(self):
73 """Test for refresh_volumes method."""
74 d = defer.Deferred()
75
76=== modified file 'ubuntuone/platform/linux/tools.py'
77--- ubuntuone/platform/linux/tools.py 2011-03-01 20:57:23 +0000
78+++ ubuntuone/platform/linux/tools.py 2011-04-04 15:36:35 +0000
79@@ -732,11 +732,14 @@
80 self.log.debug('is_files_sync_enabled')
81 return get_user_config().get_files_sync_enabled()
82
83+ @defer.inlineCallbacks
84 def enable_files_sync(self, enabled):
85 """Enable/disable files sync."""
86- self.log.debug('enable_files_sync %d', enabled)
87 config = get_user_config()
88- if config.get_files_sync_enabled():
89+ was_enabled = config.get_files_sync_enabled()
90+ self.log.debug('enable_files_sync: enable? %r was enabled? %r',
91+ enabled, was_enabled)
92+ if was_enabled:
93 d = defer.Deferred()
94 config_client = DBusClient(self.bus, '/config',
95 DBUS_IFACE_CONFIG_NAME)
96@@ -744,14 +747,16 @@
97 enabled,
98 reply_handler=d.callback,
99 error_handler=d.errback)
100- config.set_files_sync_enabled(False)
101- return d
102+ yield d
103+ config.set_files_sync_enabled(enabled)
104+ if not enabled:
105+ # User requested the service to be disabled
106+ self.quit()
107 else:
108 if enabled:
109 config.set_files_sync_enabled(True)
110 config.save()
111 self.start()
112- return defer.succeed(None)
113
114 def refresh_volumes(self):
115 """Call refresh_volumes method via DBus.

Subscribers

People subscribed via source and target branches