Merge lp:~mvo/software-center/lp1043152 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3134
Proposed branch: lp:~mvo/software-center/lp1043152
Merge into: lp:software-center
Diff against target: 69 lines (+27/-10)
2 files modified
softwarecenter/backend/scagent.py (+3/-2)
tests/test_scagent.py (+24/-8)
To merge this branch: bzr merge lp:~mvo/software-center/lp1043152
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+121845@code.launchpad.net

Description of the change

This ensures that whitespaces in packagenames are properly stripped

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

Thanks Michael!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/scagent.py'
2--- softwarecenter/backend/scagent.py 2012-07-02 16:26:08 +0000
3+++ softwarecenter/backend/scagent.py 2012-08-29 12:19:19 +0000
4@@ -132,9 +132,10 @@
5 # allow having urls to click on in a banner
6 if not hasattr(exhibit, "click_url"):
7 exhibit.click_url = ""
8- # ensure to fix #1004417
9+ # ensure to fix #1004417 and #1043152
10 if exhibit.package_names:
11- exhibit.package_names = exhibit.package_names.strip()
12+ exhibit.package_names = ",".join(
13+ [s.strip() for s in exhibit.package_names.split(",")])
14 self.emit("exhibits", exhibits)
15
16 if __name__ == "__main__":
17
18=== modified file 'tests/test_scagent.py'
19--- tests/test_scagent.py 2012-05-31 12:28:46 +0000
20+++ tests/test_scagent.py 2012-08-29 12:19:19 +0000
21@@ -53,24 +53,40 @@
22 'SoftwareCenterAgentAPI', 'subscriptions_for_me',
23 complete_only=True)
24
25+
26+class RegressionsTestCase(unittest.TestCase):
27+
28+ def setUp(self):
29+ self.sca = SoftwareCenterAgent()
30+ self.sca.emit = Mock()
31+
32+ def _get_exhibit_list_from_emit_call(self):
33+ args, kwargs = self.sca.emit.call_args
34+ scagent, exhibit_list = args
35+ return exhibit_list
36+
37 def test_regression_lp1004417(self):
38 mock_ex = Mock()
39 mock_ex.package_names = "foo,bar\n\r"
40 results = [mock_ex]
41- sca = SoftwareCenterAgent()
42- sca.emit = Mock()
43- sca._on_exhibits_data_available(None, results)
44- self.assertTrue(sca.emit.called)
45- # get the args to "emit()"
46- args, kwargs = sca.emit.call_args
47- # split the args up
48- scagent, exhibit_list = args
49+ self.sca._on_exhibits_data_available(None, results)
50+ self.assertTrue(self.sca.emit.called)
51 # and ensure we get the right list len
52+ exhibit_list = self._get_exhibit_list_from_emit_call()
53 self.assertEqual(len(exhibit_list), 1)
54 # and the right data in the list
55 exhibit = exhibit_list[0]
56 self.assertEqual(exhibit.package_names, "foo,bar")
57 self.assertFalse(exhibit.package_names.endswith("\n\r"))
58
59+ def test_regression_lp1043152(self):
60+ mock_ex = Mock()
61+ mock_ex.package_names = "moo, baa, lalala"
62+ results = [mock_ex]
63+ self.sca._on_exhibits_data_available(None, results)
64+ # ensure that the right data in the list
65+ exhibit = self._get_exhibit_list_from_emit_call()[0]
66+ self.assertEqual(exhibit.package_names, "moo,baa,lalala")
67+
68 if __name__ == "__main__":
69 unittest.main()

Subscribers

People subscribed via source and target branches