Merge lp:~mandel/ubuntuone-client/add_dbus_status_signal_tests into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: John O'Brien
Approved revision: 862
Merged at revision: 878
Proposed branch: lp:~mandel/ubuntuone-client/add_dbus_status_signal_tests
Merge into: lp:ubuntuone-client
Diff against target: 174 lines (+128/-4)
2 files modified
tests/platform/linux/test_dbus.py (+127/-3)
ubuntuone/platform/linux/dbus_interface.py (+1/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/add_dbus_status_signal_tests
Reviewer Review Type Date Requested Status
John O'Brien (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+50340@code.launchpad.net

Commit message

Fixes bug with signal and add extra tests tat will ensure that the emit methods work as expected.

Description of the change

Fixes bug with signal and add extra tests tat will ensure that the emit methods work as expected.

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve
Revision history for this message
John O'Brien (jdobrien) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/linux/test_dbus.py'
2--- tests/platform/linux/test_dbus.py 2011-02-16 12:14:20 +0000
3+++ tests/platform/linux/test_dbus.py 2011-02-18 14:53:45 +0000
4@@ -25,6 +25,7 @@
5 import dbus
6 from dbus.mainloop.glib import DBusGMainLoop
7 from dbus import exceptions
8+from mocker import MockerTestCase
9 from twisted.internet import defer, reactor
10 from twisted.python import failure
11
12@@ -41,6 +42,9 @@
13 SyncdaemonEventListener
14 )
15 from ubuntuone.platform.linux.dbus_interface import (
16+ AllEventsSender,
17+ bool_str,
18+ DBusExposedObject,
19 DBUS_IFACE_STATUS_NAME,
20 DBUS_IFACE_EVENTS_NAME,
21 DBUS_IFACE_FS_NAME,
22@@ -50,9 +54,11 @@
23 DBUS_IFACE_FOLDERS_NAME,
24 DBUS_IFACE_PUBLIC_FILES_NAME,
25 DBUS_CREDENTIALS_IFACE,
26- DBusInterface, bool_str,
27- logger, NoAccessToken, DBusExposedObject, AllEventsSender,
28- NM_STATE_CONNECTED, NM_STATE_DISCONNECTED
29+ DBusInterface,
30+ logger,
31+ NM_STATE_CONNECTED,
32+ NM_STATE_DISCONNECTED,
33+ NoAccessToken,
34 )
35 from ubuntuone.platform.linux import ExternalInterface, get_udf_path
36 from ubuntuone.syncdaemon import action_queue
37@@ -3486,6 +3492,124 @@
38 error_handler=self.error_handler)
39 yield d
40
41+class TestStatusEmitSignals(DBusTwistedTestCase, MockerTestCase):
42+ """Test that the emit method have been correctly implemented."""
43+
44+ def setUp(self):
45+ """Setup tests."""
46+ super(TestStatusEmitSignals, self).setUp()
47+ self.signal_method = self.mocker.mock()
48+
49+ def test_emit_content_queue_changed(self):
50+ """Emit ContentQueueChanged."""
51+ self.status.ContentQueueChanged = self.signal_method
52+ self.signal_method()
53+ self.mocker.replay()
54+ # will assert that the signal method was called
55+ self.status.emit_content_queue_changed()
56+
57+ def test_emit_invalid_name(self):
58+ """Emit InvalidName."""
59+ dirname = 'dirname'
60+ filename = 'filename'
61+ self.status.InvalidName = self.signal_method
62+ self.signal_method(unicode(dirname), str(filename))
63+ self.mocker.replay()
64+ self.status.emit_invalid_name(dirname, filename)
65+
66+ def test_emit_broken_node(self):
67+ """Emit BrokenNode."""
68+ volume_id = 'volume_id'
69+ node_id = 'node_id'
70+ mdid = 'mdid'
71+ path = 'path'
72+ self.status.BrokenNode = self.signal_method
73+ self.signal_method(volume_id, node_id, mdid, path.decode('utf8'))
74+ self.mocker.replay()
75+ self.status.emit_broken_node(volume_id, node_id, mdid,
76+ path.decode('utf8'))
77+
78+ def test_emit_status_changed(self):
79+ """Emit StatusChanged."""
80+ status = 'status'
81+ status_mock = self.mocker.mock()
82+ self.status.syncdaemon_status = status_mock
83+ status_mock.current_status()
84+ self.mocker.result(status)
85+ self.status.StatusChanged = self.signal_method
86+ self.signal_method(status)
87+ self.mocker.replay()
88+ self.status.emit_status_changed(status)
89+
90+ def test_emit_download_started(self):
91+ """Emit DownloadStarted."""
92+ download = 'download'
93+ self.status.DownloadStarted = self.signal_method
94+ self.signal_method(download)
95+ self.mocker.replay()
96+ self.status.emit_download_started(download)
97+
98+ def test_emit_download_file_progress(self):
99+ """Emit DownloadFileProgress."""
100+ download = 'download'
101+ string_info = {'blah':'3', 'do':'4'}
102+ self.status.DownloadFileProgress = self.signal_method
103+ self.signal_method(download, string_info)
104+ self.mocker.replay()
105+ self.status.emit_download_file_progress(download, blah=3, do=4)
106+
107+ def test_emit_download_finished(self):
108+ """Emit DownloadFinished."""
109+ download = 'download'
110+ string_info = {'blah':'3', 'do':'4'}
111+ self.status.DownloadFinished = self.signal_method
112+ self.signal_method(download, string_info)
113+ self.mocker.replay()
114+ self.status.emit_download_finished(download, blah=3, do=4)
115+
116+ def test_emit_upload_started(self):
117+ """Emit UploadStarted."""
118+ upload = 'upload'
119+ self.status.UploadStarted = self.signal_method
120+ self.signal_method(upload)
121+ self.mocker.replay()
122+ self.status.emit_upload_started(upload)
123+
124+ def test_emit_upload_file_progress(self):
125+ """Emit UploadFileProgress."""
126+ upload = 'upload'
127+ string_info = {'blah':'3', 'do':'4'}
128+ self.status.UploadFileProgress = self.signal_method
129+ self.signal_method(upload , string_info)
130+ self.mocker.replay()
131+ self.status.emit_upload_file_progress(upload , blah=3, do=4)
132+
133+ def test_emit_upload_finished(self):
134+ """Emit UploadFinished."""
135+ upload = 'upload'
136+ string_info = {'blah':'3', 'do':'4'}
137+ self.status.UploadFinished= self.signal_method
138+ self.signal_method(upload , string_info)
139+ self.mocker.replay()
140+ self.status.emit_upload_finished(upload, blah=3, do=4)
141+
142+ def test_emit_account_changed(self):
143+ """Emit AccountChanged."""
144+ info_dict = {'purchased_bytes': unicode('34')}
145+ account_info = self.mocker.mock()
146+ account_info.purchased_bytes
147+ self.mocker.result('34')
148+ self.status.AccountChanged = self.signal_method
149+ self.signal_method(info_dict)
150+ self.mocker.replay()
151+ self.status.emit_account_changed(account_info)
152+
153+ def test_emit_metaqueue_changed(self):
154+ """Emit MetaQueueChanged."""
155+ self.status.MetaQueueChanged = self.signal_method
156+ self.signal_method()
157+ self.mocker.replay()
158+ self.status.emit_metaqueue_changed()
159
160 def test_suite():
161 """Collect these tests only on linux."""
162
163=== modified file 'ubuntuone/platform/linux/dbus_interface.py'
164--- ubuntuone/platform/linux/dbus_interface.py 2011-02-17 16:53:40 +0000
165+++ ubuntuone/platform/linux/dbus_interface.py 2011-02-18 14:53:45 +0000
166@@ -261,7 +261,7 @@
167
168 def emit_status_changed(self, state):
169 """Emit StatusChanged."""
170- self.StatusChanged(self._get_current_state())
171+ self.StatusChanged(self.syncdaemon_status.current_status())
172
173 def emit_download_started(self, download):
174 """Emit DownloadStarted."""

Subscribers

People subscribed via source and target branches