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
=== modified file 'run-tests'
--- run-tests 2013-01-04 22:01:11 +0000
+++ run-tests 2013-01-30 16:24:21 +0000
@@ -1,7 +1,6 @@
1#!/bin/bash1#!/bin/bash
2# Author: Natalia Bidart <natalia.bidart@canonical.com>
3#2#
4# Copyright 2010 Canonical Ltd.3# Copyright 2010-2012 Canonical Ltd.
5#4#
6# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
7# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -14,11 +13,13 @@
14#13#
15# You should have received a copy of the GNU General Public License along14# 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/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16set -e
17
17./setup.py build18./setup.py build
18export PYTHONPATH=ubuntuone19u1trial ubuntuone
19USE_PYFLAKES=1 u1lint .20USE_PYFLAKES=1 u1lint .
20if [ -x `which pep8` ]; then21if [ -x `which pep8` ]; then
21 pep8 --repeat .22 pep8 --exclude '.bzr,.pc,build' .
22else23else
23 echo "Please install the 'pep8' package."24 echo "Please install the 'pep8' package."
24fi25fi
2526
=== modified file 'setup.py'
--- setup.py 2013-01-08 21:51:20 +0000
+++ setup.py 2013-01-30 16:24:21 +0000
@@ -1,4 +1,18 @@
1#!/usr/bin/python1#!/usr/bin/python
2# Copyright (C) 2009-2013 Canonical, Ltd.
3#
4# This library is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License
6# version 3.0 as published by the Free Software Foundation.
7#
8# This library is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU Lesser General Public License version 3.0 for more details.
12#
13# You should have received a copy of the GNU Lesser General Public
14# License along with this library. If not, see
15# <http://www.gnu.org/licenses/>.
2"""Setup script for Ubuntu One Music Store plug-in for Rhythmbox."""16"""Setup script for Ubuntu One Music Store plug-in for Rhythmbox."""
317
4import DistUtilsExtra.auto18import DistUtilsExtra.auto
519
=== added file 'ubuntuone/__init__.py'
--- ubuntuone/__init__.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/__init__.py 2013-01-30 16:24:21 +0000
@@ -0,0 +1,16 @@
1# Copyright (C) 2013 Canonical, Ltd.
2#
3# This library is free software; you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License
5# version 3.0 as published by the Free Software Foundation.
6#
7# This library is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Lesser General Public License version 3.0 for more details.
11#
12# You should have received a copy of the GNU Lesser General Public
13# License along with this library. If not, see
14# <http://www.gnu.org/licenses/>.
15"""So we can import the plug-in in tests."""
16__import__('pkg_resources').declare_namespace(__name__)
017
=== added directory 'ubuntuone/tests'
=== added file 'ubuntuone/tests/__init__.py'
--- ubuntuone/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/tests/__init__.py 2013-01-30 16:24:21 +0000
@@ -0,0 +1,15 @@
1# Copyright (C) 2013 Canonical, Ltd.
2#
3# This library is free software; you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License
5# version 3.0 as published by the Free Software Foundation.
6#
7# This library is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Lesser General Public License version 3.0 for more details.
11#
12# You should have received a copy of the GNU Lesser General Public
13# License along with this library. If not, see
14# <http://www.gnu.org/licenses/>.
15"""Tests for the Ubuntu One extension for Rhythmbox."""
016
=== added file 'ubuntuone/tests/test_ubuntuone.py'
--- ubuntuone/tests/test_ubuntuone.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/tests/test_ubuntuone.py 2013-01-30 16:24:21 +0000
@@ -0,0 +1,136 @@
1# Copyright (C) 2013 Canonical, Ltd.
2#
3# This library is free software; you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License
5# version 3.0 as published by the Free Software Foundation.
6#
7# This library is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Lesser General Public License version 3.0 for more details.
11#
12# You should have received a copy of the GNU Lesser General Public
13# License along with this library. If not, see
14# <http://www.gnu.org/licenses/>.
15"""Tests for the main plug-in module."""
16
17from __future__ import print_function, unicode_literals
18
19import os
20import ubuntuone.ubuntuone as rbplugin
21
22from dirspec.utils import user_home
23from gi.repository import Gio, GObject
24from twisted.internet.defer import inlineCallbacks
25from ubuntuone.devtools.testcases.dbus import DBusTestCase
26
27
28class FakeSettings(GObject.GObject):
29 """Fake settings object."""
30 __gsignals__ = {
31 b'changed': (
32 GObject.SIGNAL_RUN_LAST | GObject.SIGNAL_DETAILED,
33 GObject.TYPE_NONE, (str,)),
34 }
35 values = {}
36
37 def get_strv(self, key):
38 """Get the value for key."""
39 value = self.values.get(key, [])
40 assert isinstance(value, list), 'Value must be type list.'
41 return value
42
43 def set_strv(self, key, value):
44 """Set the value for key."""
45 assert isinstance(value, list), 'Value must be type list.'
46 self.values[key] = value
47
48 @property
49 def locations(self):
50 """Return the currently set locations key value."""
51 return self.get_strv('locations')
52
53 def set_locations(self, value):
54 """Set the locations key value."""
55 self.set_strv('locations', value)
56
57
58class FakeDB(GObject.GObject):
59 """Fake DB object for tests."""
60 entries = {}
61
62 def entry_lookup_by_location(self, uri):
63 """Lookup an entry for the URI."""
64 return self.entries.get(uri, None)
65
66 def add_uri(self, uri):
67 """Add a URI to the entries list."""
68 self.entries[uri] = uri
69
70
71class FakeShell(GObject.GObject):
72 """Fake shell class to store the db property object."""
73 db = GObject.property(type=GObject.GObject)
74
75
76class ExtensionTestCase(DBusTestCase):
77 """Tests for the main extension class."""
78
79 @inlineCallbacks
80 def setUp(self):
81 """Prepare the test."""
82 yield super(ExtensionTestCase, self).setUp()
83 self.settings = FakeSettings()
84 self.patch(Gio, 'Settings', lambda _: self.settings)
85 self.plugin = rbplugin.UbuntuOnePlugin()
86 self.db = FakeDB()
87 shell = FakeShell()
88 shell.db = self.db
89 self.plugin.object = shell
90 self.lib_uri = Gio.File.new_for_path(rbplugin.U1LIBRARYPATH).get_uri()
91
92 def test_add_location_exists(self):
93 """Test that the library location doesn't get added twice."""
94 expected = [self.lib_uri]
95 self.settings.set_locations(expected)
96 self.plugin._locations_changed()
97 self.assertEqual(self.settings.locations, expected)
98
99 def test_add_location_missing(self):
100 """Test that adding the library location works when missing."""
101 expected = [self.lib_uri]
102 self.plugin._locations_changed()
103 self.assertEqual(self.settings.locations, expected)
104
105 def test_add_location_with_other(self):
106 """Test that location gets added, when another library path exists."""
107 music_uri = Gio.File.new_for_path(
108 os.path.join(user_home, 'Music')).get_uri()
109 self.settings.set_locations([music_uri])
110 expected = [music_uri, self.lib_uri]
111 self.plugin._locations_changed()
112 self.assertEqual(self.settings.locations, expected)
113
114 def test_del_location_bad_uri(self):
115 """Test that removing the old badly formated URI works."""
116 expected = [self.lib_uri]
117 self.settings.set_locations(['file://%s' % rbplugin.U1LIBRARYPATH])
118 self.plugin._locations_changed()
119 self.assertEqual(self.settings.locations, expected)
120
121 def test_del_location_non_uri(self):
122 """Test that removing the old non-URI path value works."""
123 expected = [self.lib_uri]
124 self.settings.set_locations([rbplugin.U1LIBRARYPATH])
125 self.plugin._locations_changed()
126 self.assertEqual(self.settings.locations, expected)
127
128 def test_download_finished(self):
129 """Test that the download finished call adds a track to the library."""
130 self.addCleanup(self.plugin.do_deactivate)
131 self.plugin.do_activate()
132 path = os.path.join(rbplugin.U1LIBRARYPATH,
133 'Artist', 'Album', 'Track.mp3')
134 expected = Gio.File.new_for_path(path).get_uri()
135 self.plugin.download_finished(path, None)
136 self.assertEqual(self.db.entry_lookup_by_location(expected), expected)
0137
=== modified file 'ubuntuone/ubuntuone.py'
--- ubuntuone/ubuntuone.py 2013-01-02 20:57:50 +0000
+++ ubuntuone/ubuntuone.py 2013-01-30 16:24:21 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009-2012 Canonical, Ltd.1# Copyright (C) 2009-2013 Canonical, Ltd.
2#2#
3# This library is free software; you can redistribute it and/or modify3# This library is free software; you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License4# it under the terms of the GNU Lesser General Public License
@@ -19,9 +19,12 @@
19import os19import os
2020
21from dbus import SessionBus, DBusException21from dbus import SessionBus, DBusException
22from dbus.mainloop.glib import DBusGMainLoop
22from dirspec.utils import user_home23from dirspec.utils import user_home
23from gi.repository import Gio, GObject, Peas24from gi.repository import Gio, GObject, Peas
2425
26DBusGMainLoop(set_as_default=True)
27
25U1LIBRARYPATH = os.path.join(user_home, '.ubuntuone',28U1LIBRARYPATH = os.path.join(user_home, '.ubuntuone',
26 'Purchased from Ubuntu One')29 'Purchased from Ubuntu One')
2730
@@ -96,7 +99,7 @@
9699
97 # Disconnect the signal handler for downloads100 # Disconnect the signal handler for downloads
98 try:101 try:
99 self.bus.remove_signal_handler(self.download_finished,102 self._bus.remove_signal_receiver(self.download_finished,
100 signal_name='DownloadFinished')103 signal_name='DownloadFinished')
101 except DBusException:104 except DBusException:
102 return105 return

Subscribers

People subscribed via source and target branches

to all changes: