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
=== modified file 'tests/platform/linux/test_dbus.py'
--- tests/platform/linux/test_dbus.py 2011-02-16 12:14:20 +0000
+++ tests/platform/linux/test_dbus.py 2011-02-18 14:53:45 +0000
@@ -25,6 +25,7 @@
25import dbus25import dbus
26from dbus.mainloop.glib import DBusGMainLoop26from dbus.mainloop.glib import DBusGMainLoop
27from dbus import exceptions27from dbus import exceptions
28from mocker import MockerTestCase
28from twisted.internet import defer, reactor29from twisted.internet import defer, reactor
29from twisted.python import failure30from twisted.python import failure
3031
@@ -41,6 +42,9 @@
41 SyncdaemonEventListener42 SyncdaemonEventListener
42)43)
43from ubuntuone.platform.linux.dbus_interface import (44from ubuntuone.platform.linux.dbus_interface import (
45 AllEventsSender,
46 bool_str,
47 DBusExposedObject,
44 DBUS_IFACE_STATUS_NAME,48 DBUS_IFACE_STATUS_NAME,
45 DBUS_IFACE_EVENTS_NAME,49 DBUS_IFACE_EVENTS_NAME,
46 DBUS_IFACE_FS_NAME,50 DBUS_IFACE_FS_NAME,
@@ -50,9 +54,11 @@
50 DBUS_IFACE_FOLDERS_NAME,54 DBUS_IFACE_FOLDERS_NAME,
51 DBUS_IFACE_PUBLIC_FILES_NAME,55 DBUS_IFACE_PUBLIC_FILES_NAME,
52 DBUS_CREDENTIALS_IFACE,56 DBUS_CREDENTIALS_IFACE,
53 DBusInterface, bool_str,57 DBusInterface,
54 logger, NoAccessToken, DBusExposedObject, AllEventsSender,58 logger,
55 NM_STATE_CONNECTED, NM_STATE_DISCONNECTED59 NM_STATE_CONNECTED,
60 NM_STATE_DISCONNECTED,
61 NoAccessToken,
56)62)
57from ubuntuone.platform.linux import ExternalInterface, get_udf_path63from ubuntuone.platform.linux import ExternalInterface, get_udf_path
58from ubuntuone.syncdaemon import action_queue64from ubuntuone.syncdaemon import action_queue
@@ -3486,6 +3492,124 @@
3486 error_handler=self.error_handler)3492 error_handler=self.error_handler)
3487 yield d3493 yield d
34883494
3495class TestStatusEmitSignals(DBusTwistedTestCase, MockerTestCase):
3496 """Test that the emit method have been correctly implemented."""
3497
3498 def setUp(self):
3499 """Setup tests."""
3500 super(TestStatusEmitSignals, self).setUp()
3501 self.signal_method = self.mocker.mock()
3502
3503 def test_emit_content_queue_changed(self):
3504 """Emit ContentQueueChanged."""
3505 self.status.ContentQueueChanged = self.signal_method
3506 self.signal_method()
3507 self.mocker.replay()
3508 # will assert that the signal method was called
3509 self.status.emit_content_queue_changed()
3510
3511 def test_emit_invalid_name(self):
3512 """Emit InvalidName."""
3513 dirname = 'dirname'
3514 filename = 'filename'
3515 self.status.InvalidName = self.signal_method
3516 self.signal_method(unicode(dirname), str(filename))
3517 self.mocker.replay()
3518 self.status.emit_invalid_name(dirname, filename)
3519
3520 def test_emit_broken_node(self):
3521 """Emit BrokenNode."""
3522 volume_id = 'volume_id'
3523 node_id = 'node_id'
3524 mdid = 'mdid'
3525 path = 'path'
3526 self.status.BrokenNode = self.signal_method
3527 self.signal_method(volume_id, node_id, mdid, path.decode('utf8'))
3528 self.mocker.replay()
3529 self.status.emit_broken_node(volume_id, node_id, mdid,
3530 path.decode('utf8'))
3531
3532 def test_emit_status_changed(self):
3533 """Emit StatusChanged."""
3534 status = 'status'
3535 status_mock = self.mocker.mock()
3536 self.status.syncdaemon_status = status_mock
3537 status_mock.current_status()
3538 self.mocker.result(status)
3539 self.status.StatusChanged = self.signal_method
3540 self.signal_method(status)
3541 self.mocker.replay()
3542 self.status.emit_status_changed(status)
3543
3544 def test_emit_download_started(self):
3545 """Emit DownloadStarted."""
3546 download = 'download'
3547 self.status.DownloadStarted = self.signal_method
3548 self.signal_method(download)
3549 self.mocker.replay()
3550 self.status.emit_download_started(download)
3551
3552 def test_emit_download_file_progress(self):
3553 """Emit DownloadFileProgress."""
3554 download = 'download'
3555 string_info = {'blah':'3', 'do':'4'}
3556 self.status.DownloadFileProgress = self.signal_method
3557 self.signal_method(download, string_info)
3558 self.mocker.replay()
3559 self.status.emit_download_file_progress(download, blah=3, do=4)
3560
3561 def test_emit_download_finished(self):
3562 """Emit DownloadFinished."""
3563 download = 'download'
3564 string_info = {'blah':'3', 'do':'4'}
3565 self.status.DownloadFinished = self.signal_method
3566 self.signal_method(download, string_info)
3567 self.mocker.replay()
3568 self.status.emit_download_finished(download, blah=3, do=4)
3569
3570 def test_emit_upload_started(self):
3571 """Emit UploadStarted."""
3572 upload = 'upload'
3573 self.status.UploadStarted = self.signal_method
3574 self.signal_method(upload)
3575 self.mocker.replay()
3576 self.status.emit_upload_started(upload)
3577
3578 def test_emit_upload_file_progress(self):
3579 """Emit UploadFileProgress."""
3580 upload = 'upload'
3581 string_info = {'blah':'3', 'do':'4'}
3582 self.status.UploadFileProgress = self.signal_method
3583 self.signal_method(upload , string_info)
3584 self.mocker.replay()
3585 self.status.emit_upload_file_progress(upload , blah=3, do=4)
3586
3587 def test_emit_upload_finished(self):
3588 """Emit UploadFinished."""
3589 upload = 'upload'
3590 string_info = {'blah':'3', 'do':'4'}
3591 self.status.UploadFinished= self.signal_method
3592 self.signal_method(upload , string_info)
3593 self.mocker.replay()
3594 self.status.emit_upload_finished(upload, blah=3, do=4)
3595
3596 def test_emit_account_changed(self):
3597 """Emit AccountChanged."""
3598 info_dict = {'purchased_bytes': unicode('34')}
3599 account_info = self.mocker.mock()
3600 account_info.purchased_bytes
3601 self.mocker.result('34')
3602 self.status.AccountChanged = self.signal_method
3603 self.signal_method(info_dict)
3604 self.mocker.replay()
3605 self.status.emit_account_changed(account_info)
3606
3607 def test_emit_metaqueue_changed(self):
3608 """Emit MetaQueueChanged."""
3609 self.status.MetaQueueChanged = self.signal_method
3610 self.signal_method()
3611 self.mocker.replay()
3612 self.status.emit_metaqueue_changed()
34893613
3490def test_suite():3614def test_suite():
3491 """Collect these tests only on linux."""3615 """Collect these tests only on linux."""
34923616
=== modified file 'ubuntuone/platform/linux/dbus_interface.py'
--- ubuntuone/platform/linux/dbus_interface.py 2011-02-17 16:53:40 +0000
+++ ubuntuone/platform/linux/dbus_interface.py 2011-02-18 14:53:45 +0000
@@ -261,7 +261,7 @@
261261
262 def emit_status_changed(self, state):262 def emit_status_changed(self, state):
263 """Emit StatusChanged."""263 """Emit StatusChanged."""
264 self.StatusChanged(self._get_current_state())264 self.StatusChanged(self.syncdaemon_status.current_status())
265265
266 def emit_download_started(self, download):266 def emit_download_started(self, download):
267 """Emit DownloadStarted."""267 """Emit DownloadStarted."""

Subscribers

People subscribed via source and target branches