Merge lp:~mvo/software-center/fix-fixme-lp1045330 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3150
Proposed branch: lp:~mvo/software-center/fix-fixme-lp1045330
Merge into: lp:software-center
Diff against target: 84 lines (+25/-11)
2 files modified
tests/test_dataprovider.py (+7/-4)
tests/utils.py (+18/-7)
To merge this branch: bzr merge lp:~mvo/software-center/fix-fixme-lp1045330
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+122806@code.launchpad.net

Description of the change

This branch addresses the code review comment for lp1045330 and
fixes a FIXME in the dataprovider test by providing its own private
dbus connection instead of using the system bus.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thanks, Michael! In the review you mentioned I was actually referring to the FIXMEs in the actual code, although I do realize that those changes are dependent on server-side work and so would not likely be part of the targeted change for the bug 1045330 fix. Although it it always nice to do, I personally don't think it's required to fix any FIXMEs that are not specifically related to the specific code change in the merge proposal.

So, I apologize for the misunderstanding! And I thank you for making the fix in the MP!! Certainly, any FIXME cleared is a very good thing!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_dataprovider.py'
2--- tests/test_dataprovider.py 2012-09-04 09:13:13 +0000
3+++ tests/test_dataprovider.py 2012-09-05 07:46:19 +0000
4@@ -3,19 +3,22 @@
5 import unittest
6
7 from tests.utils import (
8+ kill_process,
9 setup_test_env,
10+ start_dbus_daemon,
11 )
12 setup_test_env()
13
14 from softwarecenter.db.dataprovider import SoftwareCenterDataProvider
15
16
17+
18 class DataProviderTestCase(unittest.TestCase):
19
20 @classmethod
21 def setUpClass(cls):
22- # FIXME: get a private test bus here instead
23- cls.bus = dbus.SessionBus()
24+ cls.proc, dbus_address = start_dbus_daemon()
25+ cls.bus = dbus.bus.BusConnection(dbus_address)
26 bus_name = dbus.service.BusName(
27 'com.ubuntu.SoftwareCenterDataProvider', cls.bus)
28 # get the provider
29@@ -24,7 +27,8 @@
30 @classmethod
31 def tearDownClass(cls):
32 cls.provider.stop()
33-
34+ kill_process(cls.proc)
35+
36 def test_have_data_in_db(self):
37 self.assertTrue(len(self.provider.db) > 100)
38
39@@ -36,6 +40,5 @@
40 self.assertEqual(result["pkgname"], "gedit")
41 self.assertEqual(result["price"], "")
42
43-
44 if __name__ == "__main__":
45 unittest.main()
46
47=== modified file 'tests/utils.py'
48--- tests/utils.py 2012-08-23 14:37:28 +0000
49+++ tests/utils.py 2012-09-05 07:46:19 +0000
50@@ -54,16 +54,27 @@
51 UTILS_DIR = os.path.abspath(os.path.join('.', 'utils'))
52
53
54+def start_dbus_daemon():
55+ proc = subprocess.Popen(["dbus-daemon",
56+ "--session",
57+ "--nofork",
58+ "--print-address"],
59+ stdout=subprocess.PIPE)
60+ dbus_address = proc.stdout.readline().strip()
61+ return proc, dbus_address
62+
63+
64+def kill_process(proc):
65+ """Takes a subprocess process and kills it"""
66+ do_events_with_sleep()
67+ proc.kill()
68+ proc.wait()
69+
70+
71 def start_dummy_backend():
72 global m_dbus, m_polkit, m_aptd
73- # start private dbus
74- m_dbus = subprocess.Popen(["dbus-daemon",
75- "--session",
76- "--nofork",
77- "--print-address"],
78- stdout=subprocess.PIPE)
79 # get and store address
80- bus_address = m_dbus.stdout.readline().strip()
81+ m_dbus, bus_address = start_dbus_daemon()
82 os.environ["SOFTWARE_CENTER_APTD_FAKE"] = bus_address
83 # start fake polkit from python-aptdaemon.test
84 env = {"DBUS_SESSION_BUS_ADDRESS": bus_address,

Subscribers

People subscribed via source and target branches