Merge lp:~dobey/rhythmbox-ubuntuone/update-4-2 into lp:rhythmbox-ubuntuone/stable-4-2

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 124
Merged at revision: 124
Proposed branch: lp:~dobey/rhythmbox-ubuntuone/update-4-2
Merge into: lp:rhythmbox-ubuntuone/stable-4-2
Diff against target: 267 lines (+192/-7)
6 files modified
run-tests (+5/-4)
setup.py (+14/-0)
ubuntuone/__init__.py (+16/-0)
ubuntuone/tests/__init__.py (+15/-0)
ubuntuone/tests/test_ubuntuone.py (+136/-0)
ubuntuone/ubuntuone.py (+6/-3)
To merge this branch: bzr merge lp:~dobey/rhythmbox-ubuntuone/update-4-2
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Review via email: mp+145648@code.launchpad.net

Commit message

[Rodney Dawes]

    Tell dbus to use the glib main loop for async support and signal handling.
    Add a test suite so we can prevent more bugs from landing in trunk.
    Use the correct attribute name, and dbus API to remove the signal handler.
    Fix lint/pep8 warnings.
    Use set -e in run-tests script to stop on errors.

To post a comment you must log in.
Revision history for this message
Mike McCracken (mikemc) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (3.5 KiB)

The attempt to merge lp:~dobey/rhythmbox-ubuntuone/update-4-2 into lp:rhythmbox-ubuntuone/stable-4-2 failed. Below is the output from the failed tests.

running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/ubuntuone
creating build/lib.linux-x86_64-2.7/ubuntuone/tests
copying ubuntuone/tests/__init__.py -> build/lib.linux-x86_64-2.7/ubuntuone/tests
copying ubuntuone/tests/test_ubuntuone.py -> build/lib.linux-x86_64-2.7/ubuntuone/tests
copying ubuntuone/__init__.py -> build/lib.linux-x86_64-2.7/ubuntuone
copying ubuntuone/ubuntuone.py -> build/lib.linux-x86_64-2.7/ubuntuone
running build_i18n
intltool-update -p -g rhythmbox-ubuntuone
msgfmt po/ru.po -o build/mo/ru/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/eu.po -o build/mo/eu/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/el.po -o build/mo/el/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/fi.po -o build/mo/fi/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/cs.po -o build/mo/cs/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/hr.po -o build/mo/hr/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/da.po -o build/mo/da/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/ro.po -o build/mo/ro/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/de.po -o build/mo/de/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/he.po -o build/mo/he/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/gl.po -o build/mo/gl/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/uk.po -o build/mo/uk/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/ca.po -o build/mo/ca/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/ka.po -o build/mo/ka/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/es.po -o build/mo/es/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/en_GB.po -o build/mo/en_GB/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/nl.po -o build/mo/nl/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/fr.po -o build/mo/fr/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/fy.po -o build/mo/fy/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/pl.po -o build/mo/pl/LC_MESSAGES/rhythmbox-ubuntuone.mo
msgfmt po/sv.po -o build/mo/sv/LC_MESSAGES/rhythmbox-ubuntuone.mo
intltool-merge -d po ubuntuone/ubuntuone.plugin.in build/lib/rhythmbox/plugins/ubuntuone/ubuntuone.plugin
Merging translations into build/lib/rhythmbox/plugins/ubuntuone/ubuntuone.plugin.
running build_icons
running build_help
WARNING: the following files are not recognized by DistUtilsExtra.auto:
  run-tests
  ubuntuone/ubuntuone.plugin.in

ERROR:root:Could not find any typelib for Peas
Traceback (most recent call last):
  File "/usr/bin/u1trial", line 40, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/ubuntuone-dev-tools/ubuntuone/devtools/runners/__init__.py", line 277, in main
    suite = test_runner.get_suite(options)
  File "/usr/lib/python2.7/dist-packages/ubuntuone-dev-tools/ubuntuone/devtools/runners/__init__.py", line 173, in get_suite
    config['ignore-paths']))
  File "/usr/lib/python2.7/dist-packages/ubuntuone-dev-tools/ubuntuone/devtools/runners/__init__.py", line 157, in _collect_tests
    module_suite = self._load_unittest(filepath)
  File "/usr/lib/python2.7/dist-packages/ubuntuone-dev-tools/ubuntuone/devtools/runners/__init__.py", line 98, in _load_un...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run-tests'
2--- run-tests 2013-01-04 22:01:11 +0000
3+++ run-tests 2013-01-30 16:24:21 +0000
4@@ -1,7 +1,6 @@
5 #!/bin/bash
6-# Author: Natalia Bidart <natalia.bidart@canonical.com>
7 #
8-# Copyright 2010 Canonical Ltd.
9+# Copyright 2010-2012 Canonical Ltd.
10 #
11 # This program is free software: you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License version 3, as published
13@@ -14,11 +13,13 @@
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program. If not, see <http://www.gnu.org/licenses/>.
17+set -e
18+
19 ./setup.py build
20-export PYTHONPATH=ubuntuone
21+u1trial ubuntuone
22 USE_PYFLAKES=1 u1lint .
23 if [ -x `which pep8` ]; then
24- pep8 --repeat .
25+ pep8 --exclude '.bzr,.pc,build' .
26 else
27 echo "Please install the 'pep8' package."
28 fi
29
30=== modified file 'setup.py'
31--- setup.py 2013-01-08 21:51:20 +0000
32+++ setup.py 2013-01-30 16:24:21 +0000
33@@ -1,4 +1,18 @@
34 #!/usr/bin/python
35+# Copyright (C) 2009-2013 Canonical, Ltd.
36+#
37+# This library is free software; you can redistribute it and/or modify
38+# it under the terms of the GNU Lesser General Public License
39+# version 3.0 as published by the Free Software Foundation.
40+#
41+# This library is distributed in the hope that it will be useful,
42+# but WITHOUT ANY WARRANTY; without even the implied warranty of
43+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44+# GNU Lesser General Public License version 3.0 for more details.
45+#
46+# You should have received a copy of the GNU Lesser General Public
47+# License along with this library. If not, see
48+# <http://www.gnu.org/licenses/>.
49 """Setup script for Ubuntu One Music Store plug-in for Rhythmbox."""
50
51 import DistUtilsExtra.auto
52
53=== added file 'ubuntuone/__init__.py'
54--- ubuntuone/__init__.py 1970-01-01 00:00:00 +0000
55+++ ubuntuone/__init__.py 2013-01-30 16:24:21 +0000
56@@ -0,0 +1,16 @@
57+# Copyright (C) 2013 Canonical, Ltd.
58+#
59+# This library is free software; you can redistribute it and/or modify
60+# it under the terms of the GNU Lesser General Public License
61+# version 3.0 as published by the Free Software Foundation.
62+#
63+# This library is distributed in the hope that it will be useful,
64+# but WITHOUT ANY WARRANTY; without even the implied warranty of
65+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66+# GNU Lesser General Public License version 3.0 for more details.
67+#
68+# You should have received a copy of the GNU Lesser General Public
69+# License along with this library. If not, see
70+# <http://www.gnu.org/licenses/>.
71+"""So we can import the plug-in in tests."""
72+__import__('pkg_resources').declare_namespace(__name__)
73
74=== added directory 'ubuntuone/tests'
75=== added file 'ubuntuone/tests/__init__.py'
76--- ubuntuone/tests/__init__.py 1970-01-01 00:00:00 +0000
77+++ ubuntuone/tests/__init__.py 2013-01-30 16:24:21 +0000
78@@ -0,0 +1,15 @@
79+# Copyright (C) 2013 Canonical, Ltd.
80+#
81+# This library is free software; you can redistribute it and/or modify
82+# it under the terms of the GNU Lesser General Public License
83+# version 3.0 as published by the Free Software Foundation.
84+#
85+# This library is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU Lesser General Public License version 3.0 for more details.
89+#
90+# You should have received a copy of the GNU Lesser General Public
91+# License along with this library. If not, see
92+# <http://www.gnu.org/licenses/>.
93+"""Tests for the Ubuntu One extension for Rhythmbox."""
94
95=== added file 'ubuntuone/tests/test_ubuntuone.py'
96--- ubuntuone/tests/test_ubuntuone.py 1970-01-01 00:00:00 +0000
97+++ ubuntuone/tests/test_ubuntuone.py 2013-01-30 16:24:21 +0000
98@@ -0,0 +1,136 @@
99+# Copyright (C) 2013 Canonical, Ltd.
100+#
101+# This library is free software; you can redistribute it and/or modify
102+# it under the terms of the GNU Lesser General Public License
103+# version 3.0 as published by the Free Software Foundation.
104+#
105+# This library is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Lesser General Public License version 3.0 for more details.
109+#
110+# You should have received a copy of the GNU Lesser General Public
111+# License along with this library. If not, see
112+# <http://www.gnu.org/licenses/>.
113+"""Tests for the main plug-in module."""
114+
115+from __future__ import print_function, unicode_literals
116+
117+import os
118+import ubuntuone.ubuntuone as rbplugin
119+
120+from dirspec.utils import user_home
121+from gi.repository import Gio, GObject
122+from twisted.internet.defer import inlineCallbacks
123+from ubuntuone.devtools.testcases.dbus import DBusTestCase
124+
125+
126+class FakeSettings(GObject.GObject):
127+ """Fake settings object."""
128+ __gsignals__ = {
129+ b'changed': (
130+ GObject.SIGNAL_RUN_LAST | GObject.SIGNAL_DETAILED,
131+ GObject.TYPE_NONE, (str,)),
132+ }
133+ values = {}
134+
135+ def get_strv(self, key):
136+ """Get the value for key."""
137+ value = self.values.get(key, [])
138+ assert isinstance(value, list), 'Value must be type list.'
139+ return value
140+
141+ def set_strv(self, key, value):
142+ """Set the value for key."""
143+ assert isinstance(value, list), 'Value must be type list.'
144+ self.values[key] = value
145+
146+ @property
147+ def locations(self):
148+ """Return the currently set locations key value."""
149+ return self.get_strv('locations')
150+
151+ def set_locations(self, value):
152+ """Set the locations key value."""
153+ self.set_strv('locations', value)
154+
155+
156+class FakeDB(GObject.GObject):
157+ """Fake DB object for tests."""
158+ entries = {}
159+
160+ def entry_lookup_by_location(self, uri):
161+ """Lookup an entry for the URI."""
162+ return self.entries.get(uri, None)
163+
164+ def add_uri(self, uri):
165+ """Add a URI to the entries list."""
166+ self.entries[uri] = uri
167+
168+
169+class FakeShell(GObject.GObject):
170+ """Fake shell class to store the db property object."""
171+ db = GObject.property(type=GObject.GObject)
172+
173+
174+class ExtensionTestCase(DBusTestCase):
175+ """Tests for the main extension class."""
176+
177+ @inlineCallbacks
178+ def setUp(self):
179+ """Prepare the test."""
180+ yield super(ExtensionTestCase, self).setUp()
181+ self.settings = FakeSettings()
182+ self.patch(Gio, 'Settings', lambda _: self.settings)
183+ self.plugin = rbplugin.UbuntuOnePlugin()
184+ self.db = FakeDB()
185+ shell = FakeShell()
186+ shell.db = self.db
187+ self.plugin.object = shell
188+ self.lib_uri = Gio.File.new_for_path(rbplugin.U1LIBRARYPATH).get_uri()
189+
190+ def test_add_location_exists(self):
191+ """Test that the library location doesn't get added twice."""
192+ expected = [self.lib_uri]
193+ self.settings.set_locations(expected)
194+ self.plugin._locations_changed()
195+ self.assertEqual(self.settings.locations, expected)
196+
197+ def test_add_location_missing(self):
198+ """Test that adding the library location works when missing."""
199+ expected = [self.lib_uri]
200+ self.plugin._locations_changed()
201+ self.assertEqual(self.settings.locations, expected)
202+
203+ def test_add_location_with_other(self):
204+ """Test that location gets added, when another library path exists."""
205+ music_uri = Gio.File.new_for_path(
206+ os.path.join(user_home, 'Music')).get_uri()
207+ self.settings.set_locations([music_uri])
208+ expected = [music_uri, self.lib_uri]
209+ self.plugin._locations_changed()
210+ self.assertEqual(self.settings.locations, expected)
211+
212+ def test_del_location_bad_uri(self):
213+ """Test that removing the old badly formated URI works."""
214+ expected = [self.lib_uri]
215+ self.settings.set_locations(['file://%s' % rbplugin.U1LIBRARYPATH])
216+ self.plugin._locations_changed()
217+ self.assertEqual(self.settings.locations, expected)
218+
219+ def test_del_location_non_uri(self):
220+ """Test that removing the old non-URI path value works."""
221+ expected = [self.lib_uri]
222+ self.settings.set_locations([rbplugin.U1LIBRARYPATH])
223+ self.plugin._locations_changed()
224+ self.assertEqual(self.settings.locations, expected)
225+
226+ def test_download_finished(self):
227+ """Test that the download finished call adds a track to the library."""
228+ self.addCleanup(self.plugin.do_deactivate)
229+ self.plugin.do_activate()
230+ path = os.path.join(rbplugin.U1LIBRARYPATH,
231+ 'Artist', 'Album', 'Track.mp3')
232+ expected = Gio.File.new_for_path(path).get_uri()
233+ self.plugin.download_finished(path, None)
234+ self.assertEqual(self.db.entry_lookup_by_location(expected), expected)
235
236=== modified file 'ubuntuone/ubuntuone.py'
237--- ubuntuone/ubuntuone.py 2013-01-02 20:57:50 +0000
238+++ ubuntuone/ubuntuone.py 2013-01-30 16:24:21 +0000
239@@ -1,4 +1,4 @@
240-# Copyright (C) 2009-2012 Canonical, Ltd.
241+# Copyright (C) 2009-2013 Canonical, Ltd.
242 #
243 # This library is free software; you can redistribute it and/or modify
244 # it under the terms of the GNU Lesser General Public License
245@@ -19,9 +19,12 @@
246 import os
247
248 from dbus import SessionBus, DBusException
249+from dbus.mainloop.glib import DBusGMainLoop
250 from dirspec.utils import user_home
251 from gi.repository import Gio, GObject, Peas
252
253+DBusGMainLoop(set_as_default=True)
254+
255 U1LIBRARYPATH = os.path.join(user_home, '.ubuntuone',
256 'Purchased from Ubuntu One')
257
258@@ -96,7 +99,7 @@
259
260 # Disconnect the signal handler for downloads
261 try:
262- self.bus.remove_signal_handler(self.download_finished,
263- signal_name='DownloadFinished')
264+ self._bus.remove_signal_receiver(self.download_finished,
265+ signal_name='DownloadFinished')
266 except DBusException:
267 return

Subscribers

People subscribed via source and target branches

to all changes: