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
=== modified file 'softwarecenter/backend/scagent.py'
--- softwarecenter/backend/scagent.py 2012-07-02 16:26:08 +0000
+++ softwarecenter/backend/scagent.py 2012-08-29 12:19:19 +0000
@@ -132,9 +132,10 @@
132 # allow having urls to click on in a banner132 # allow having urls to click on in a banner
133 if not hasattr(exhibit, "click_url"):133 if not hasattr(exhibit, "click_url"):
134 exhibit.click_url = ""134 exhibit.click_url = ""
135 # ensure to fix #1004417135 # ensure to fix #1004417 and #1043152
136 if exhibit.package_names:136 if exhibit.package_names:
137 exhibit.package_names = exhibit.package_names.strip()137 exhibit.package_names = ",".join(
138 [s.strip() for s in exhibit.package_names.split(",")])
138 self.emit("exhibits", exhibits)139 self.emit("exhibits", exhibits)
139140
140if __name__ == "__main__":141if __name__ == "__main__":
141142
=== modified file 'tests/test_scagent.py'
--- tests/test_scagent.py 2012-05-31 12:28:46 +0000
+++ tests/test_scagent.py 2012-08-29 12:19:19 +0000
@@ -53,24 +53,40 @@
53 'SoftwareCenterAgentAPI', 'subscriptions_for_me',53 'SoftwareCenterAgentAPI', 'subscriptions_for_me',
54 complete_only=True)54 complete_only=True)
5555
56
57class RegressionsTestCase(unittest.TestCase):
58
59 def setUp(self):
60 self.sca = SoftwareCenterAgent()
61 self.sca.emit = Mock()
62
63 def _get_exhibit_list_from_emit_call(self):
64 args, kwargs = self.sca.emit.call_args
65 scagent, exhibit_list = args
66 return exhibit_list
67
56 def test_regression_lp1004417(self):68 def test_regression_lp1004417(self):
57 mock_ex = Mock()69 mock_ex = Mock()
58 mock_ex.package_names = "foo,bar\n\r"70 mock_ex.package_names = "foo,bar\n\r"
59 results = [mock_ex]71 results = [mock_ex]
60 sca = SoftwareCenterAgent()72 self.sca._on_exhibits_data_available(None, results)
61 sca.emit = Mock()73 self.assertTrue(self.sca.emit.called)
62 sca._on_exhibits_data_available(None, results)
63 self.assertTrue(sca.emit.called)
64 # get the args to "emit()"
65 args, kwargs = sca.emit.call_args
66 # split the args up
67 scagent, exhibit_list = args
68 # and ensure we get the right list len74 # and ensure we get the right list len
75 exhibit_list = self._get_exhibit_list_from_emit_call()
69 self.assertEqual(len(exhibit_list), 1)76 self.assertEqual(len(exhibit_list), 1)
70 # and the right data in the list77 # and the right data in the list
71 exhibit = exhibit_list[0]78 exhibit = exhibit_list[0]
72 self.assertEqual(exhibit.package_names, "foo,bar")79 self.assertEqual(exhibit.package_names, "foo,bar")
73 self.assertFalse(exhibit.package_names.endswith("\n\r"))80 self.assertFalse(exhibit.package_names.endswith("\n\r"))
7481
82 def test_regression_lp1043152(self):
83 mock_ex = Mock()
84 mock_ex.package_names = "moo, baa, lalala"
85 results = [mock_ex]
86 self.sca._on_exhibits_data_available(None, results)
87 # ensure that the right data in the list
88 exhibit = self._get_exhibit_list_from_emit_call()[0]
89 self.assertEqual(exhibit.package_names, "moo,baa,lalala")
90
75if __name__ == "__main__":91if __name__ == "__main__":
76 unittest.main()92 unittest.main()

Subscribers

People subscribed via source and target branches