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
=== modified file 'tests/test_dataprovider.py'
--- tests/test_dataprovider.py 2012-09-04 09:13:13 +0000
+++ tests/test_dataprovider.py 2012-09-05 07:46:19 +0000
@@ -3,19 +3,22 @@
3import unittest3import unittest
44
5from tests.utils import (5from tests.utils import (
6 kill_process,
6 setup_test_env,7 setup_test_env,
8 start_dbus_daemon,
7)9)
8setup_test_env()10setup_test_env()
911
10from softwarecenter.db.dataprovider import SoftwareCenterDataProvider12from softwarecenter.db.dataprovider import SoftwareCenterDataProvider
1113
1214
15
13class DataProviderTestCase(unittest.TestCase):16class DataProviderTestCase(unittest.TestCase):
1417
15 @classmethod18 @classmethod
16 def setUpClass(cls):19 def setUpClass(cls):
17 # FIXME: get a private test bus here instead20 cls.proc, dbus_address = start_dbus_daemon()
18 cls.bus = dbus.SessionBus()21 cls.bus = dbus.bus.BusConnection(dbus_address)
19 bus_name = dbus.service.BusName(22 bus_name = dbus.service.BusName(
20 'com.ubuntu.SoftwareCenterDataProvider', cls.bus)23 'com.ubuntu.SoftwareCenterDataProvider', cls.bus)
21 # get the provider24 # get the provider
@@ -24,7 +27,8 @@
24 @classmethod27 @classmethod
25 def tearDownClass(cls):28 def tearDownClass(cls):
26 cls.provider.stop()29 cls.provider.stop()
27 30 kill_process(cls.proc)
31
28 def test_have_data_in_db(self):32 def test_have_data_in_db(self):
29 self.assertTrue(len(self.provider.db) > 100)33 self.assertTrue(len(self.provider.db) > 100)
3034
@@ -36,6 +40,5 @@
36 self.assertEqual(result["pkgname"], "gedit")40 self.assertEqual(result["pkgname"], "gedit")
37 self.assertEqual(result["price"], "")41 self.assertEqual(result["price"], "")
3842
39
40if __name__ == "__main__":43if __name__ == "__main__":
41 unittest.main()44 unittest.main()
4245
=== modified file 'tests/utils.py'
--- tests/utils.py 2012-08-23 14:37:28 +0000
+++ tests/utils.py 2012-09-05 07:46:19 +0000
@@ -54,16 +54,27 @@
54UTILS_DIR = os.path.abspath(os.path.join('.', 'utils'))54UTILS_DIR = os.path.abspath(os.path.join('.', 'utils'))
5555
5656
57def start_dbus_daemon():
58 proc = subprocess.Popen(["dbus-daemon",
59 "--session",
60 "--nofork",
61 "--print-address"],
62 stdout=subprocess.PIPE)
63 dbus_address = proc.stdout.readline().strip()
64 return proc, dbus_address
65
66
67def kill_process(proc):
68 """Takes a subprocess process and kills it"""
69 do_events_with_sleep()
70 proc.kill()
71 proc.wait()
72
73
57def start_dummy_backend():74def start_dummy_backend():
58 global m_dbus, m_polkit, m_aptd75 global m_dbus, m_polkit, m_aptd
59 # start private dbus
60 m_dbus = subprocess.Popen(["dbus-daemon",
61 "--session",
62 "--nofork",
63 "--print-address"],
64 stdout=subprocess.PIPE)
65 # get and store address76 # get and store address
66 bus_address = m_dbus.stdout.readline().strip()77 m_dbus, bus_address = start_dbus_daemon()
67 os.environ["SOFTWARE_CENTER_APTD_FAKE"] = bus_address78 os.environ["SOFTWARE_CENTER_APTD_FAKE"] = bus_address
68 # start fake polkit from python-aptdaemon.test79 # start fake polkit from python-aptdaemon.test
69 env = {"DBUS_SESSION_BUS_ADDRESS": bus_address,80 env = {"DBUS_SESSION_BUS_ADDRESS": bus_address,

Subscribers

People subscribed via source and target branches