Merge lp:~mvo/software-center/launcher-integration-unit-tests into lp:~gary-lasker/software-center/launcher-integration-unit-tests

Proposed by Michael Vogt
Status: Merged
Merge reported by: Michael Vogt
Merged at revision: not available
Proposed branch: lp:~mvo/software-center/launcher-integration-unit-tests
Merge into: lp:~gary-lasker/software-center/launcher-integration-unit-tests
Diff against target: 170 lines (+51/-74)
1 file modified
test/gtk3/test_unity_launcher_integration.py (+51/-74)
To merge this branch: bzr merge lp:~mvo/software-center/launcher-integration-unit-tests
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Gary Lasker Pending
Review via email: mp+115489@code.launchpad.net

Description of the change

This branch is the result of https://code.launchpad.net/~gary-lasker/software-center/launcher-integration-unit-tests/+merge/115236

The thing that needs a extra critical look is r3062 to ensure that this does not regress on what we are testing but if not I think its a good approach to simplify and remove some duplication.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Meh, r3062 (the commit message) is misleading as its just a subset (three tests) that are consolidated.

3063. By Michael Vogt

merged from gary

Revision history for this message
Michael Vogt (mvo) wrote :

Merged into 5.2 now (after approval from Gary on irc).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'test/gtk3/test_unity_launcher_integration.py'
--- test/gtk3/test_unity_launcher_integration.py 2012-07-18 15:12:20 +0000
+++ test/gtk3/test_unity_launcher_integration.py 2012-07-18 15:26:24 +0000
@@ -109,8 +109,8 @@
109 "")109 "")
110 self._install_from_list_view(test_pkgname)110 self._install_from_list_view(test_pkgname)
111 self.assertTrue(mock_send_application_to_launcher.called)111 self.assertTrue(mock_send_application_to_launcher.called)
112 args = mock_send_application_to_launcher.call_args112 args, kwargs = mock_send_application_to_launcher.call_args
113 self._check_send_application_to_launcher_args(args[0][0], args[0][1])113 self._check_send_application_to_launcher_args(*args, **kwargs)
114114
115 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'115 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
116 '.send_application_to_launcher')116 '.send_application_to_launcher')
@@ -128,8 +128,8 @@
128 "")128 "")
129 self._navigate_to_appdetails_and_install(test_pkgname)129 self._navigate_to_appdetails_and_install(test_pkgname)
130 self.assertTrue(mock_send_application_to_launcher.called)130 self.assertTrue(mock_send_application_to_launcher.called)
131 args = mock_send_application_to_launcher.call_args131 args, kwargs = mock_send_application_to_launcher.call_args
132 self._check_send_application_to_launcher_args(args[0][0], args[0][1])132 self._check_send_application_to_launcher_args(*args, **kwargs)
133 133
134 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'134 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
135 '.send_application_to_launcher')135 '.send_application_to_launcher')
@@ -140,76 +140,47 @@
140 test_pkgname = "software-center"140 test_pkgname = "software-center"
141 self._navigate_to_appdetails_and_install(test_pkgname)141 self._navigate_to_appdetails_and_install(test_pkgname)
142 self.assertFalse(mock_send_application_to_launcher.called)142 self.assertFalse(mock_send_application_to_launcher.called)
143 143
144 @patch('softwarecenter.ui.gtk3.panes.availablepane'144 @patch('softwarecenter.ui.gtk3.panes.availablepane'
145 '.convert_desktop_file_to_installed_location')145 '.convert_desktop_file_to_installed_location')
146 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'146 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
147 '.send_application_to_launcher')147 '.send_application_to_launcher')
148 # NOTE: the order of attributes in the method call appears reversed, this148 # NOTE: the order of attributes in the method call appears reversed, this
149 # is because the patch decorators above are executed from innermost to149 # is because the patch decorators above are executed from innermost to
150 # outermost150 # outermost
151 def test_unity_launcher_integration_launcher_displayed_app(self,151 def test_unity_launcher_integration_launcher(self,
152 mock_send_application_to_launcher,152 mock_send_application_to_launcher,
153 mock_convert_desktop_file_to_installed_location):153 mock_convert_desktop_file_to_installed_location):
154 # test that the add to launcher call is made in the case where154 # this is a 3-tuple of (pkgname, desktop-file, expected_result)
155 # an application with a valid and displayable desktop file155 TEST_CASES = (
156 available_pane.add_to_launcher_enabled = True156 # normal app
157 test_pkgname = "software-center"157 ("software-center", "/usr/share/app-install/desktop/"\
158 app_install_desktop_file_path = ("/usr/share/app-install/desktop/"158 "software-center:ubuntu-software-center.desktop", True),
159 "software-center:ubuntu-software-center.desktop")159 # NoDisplay=True line
160 mock_convert_desktop_file_to_installed_location.return_value = (160 ("wine", "/usr/share/app-install/desktop/"\
161 app_install_desktop_file_path)161 "wine1.4:wine.desktop", False),
162 self._navigate_to_appdetails_and_install(test_pkgname)162 # No Exec= line
163 # make sure that the add to launcher call is made163 ("bzr", "/usr/share/app-install/desktop/"\
164 self.assertTrue(mock_send_application_to_launcher.called)164 "bzr.desktop", False)
165 165 )
166 @patch('softwarecenter.ui.gtk3.panes.availablepane'166 # run the test over all test-cases
167 '.convert_desktop_file_to_installed_location')167 available_pane.add_to_launcher_enabled = True
168 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'168 for test_pkgname, app_install_desktop_file_path, res in TEST_CASES:
169 '.send_application_to_launcher')169 # setup the mock
170 # NOTE: the order of attributes in the method call appears reversed, this170 mock_convert_desktop_file_to_installed_location.return_value = (
171 # is because the patch decorators above are executed from innermost to171 app_install_desktop_file_path)
172 # outermost172 # this is the tofu of the test
173 def test_unity_launcher_integration_no_display_in_desktop_file(self,173 self._navigate_to_appdetails_and_install(test_pkgname)
174 mock_send_application_to_launcher,174 # verify
175 mock_convert_desktop_file_to_installed_location):175 self.assertEqual(mock_send_application_to_launcher.called, res)
176 # test that the add to launcher call is *not* made in the case where176 # and reset again to ensure we don't get the call info from
177 # an application's desktop file specifies "NoDisplay=true"177 # the previous call(s)
178 available_pane.add_to_launcher_enabled = True178 mock_send_application_to_launcher.reset_mock()
179 test_pkgname = "wine"179
180 app_install_desktop_file_path = ("/usr/share/app-install/desktop/"180
181 "wine1.4:wine.desktop")181class DesktopFilepathConversionTestCase(unittest.TestCase):
182 mock_convert_desktop_file_to_installed_location.return_value = (182
183 app_install_desktop_file_path)183 def test_normal(self):
184 self._navigate_to_appdetails_and_install(test_pkgname)
185 # make sure that the add to launcher call is *not* made in the case
186 # where the desktop file specifies NoDisplay=True
187 self.assertFalse(mock_send_application_to_launcher.called)
188
189 @patch('softwarecenter.ui.gtk3.panes.availablepane'
190 '.convert_desktop_file_to_installed_location')
191 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
192 '.send_application_to_launcher')
193 # NOTE: the order of attributes in the method call appears reversed, this
194 # is because the patch decorators above are executed from innermost to
195 # outermost
196 def test_unity_launcher_integration_no_exec_in_desktop_file(self,
197 mock_send_application_to_launcher,
198 mock_convert_desktop_file_to_installed_location):
199 # test that the add to launcher call is *not* made in the case where
200 # an application's desktop file does not contain an "exec" entry
201 available_pane.add_to_launcher_enabled = True
202 test_pkgname = "bzr"
203 app_install_desktop_file_path = ("/usr/share/app-install/desktop/"
204 "bzr.desktop")
205 mock_convert_desktop_file_to_installed_location.return_value = (
206 app_install_desktop_file_path)
207 self._navigate_to_appdetails_and_install(test_pkgname)
208 # make sure that the add to launcher call is *not* made in the case
209 # where the desktop file does not contain an "exec" entry
210 self.assertFalse(mock_send_application_to_launcher.called)
211
212 def test_desktop_file_path_conversion(self):
213 # test 'normal' case184 # test 'normal' case
214 app_install_desktop_path = ("./data/app-install/desktop/" +185 app_install_desktop_path = ("./data/app-install/desktop/" +
215 "deja-dup:deja-dup.desktop")186 "deja-dup:deja-dup.desktop")
@@ -217,6 +188,8 @@
217 app_install_desktop_path, "deja-dup")188 app_install_desktop_path, "deja-dup")
218 self.assertEqual(installed_desktop_path,189 self.assertEqual(installed_desktop_path,
219 "./data/applications/deja-dup.desktop")190 "./data/applications/deja-dup.desktop")
191
192 def test_encoded_subdir(self):
220 # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop193 # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop
221 app_install_desktop_path = ("./data/app-install/desktop/" +194 app_install_desktop_path = ("./data/app-install/desktop/" +
222 "soundkonverter:" +195 "soundkonverter:" +
@@ -225,6 +198,8 @@
225 app_install_desktop_path, "soundkonverter")198 app_install_desktop_path, "soundkonverter")
226 self.assertEqual(installed_desktop_path,199 self.assertEqual(installed_desktop_path,
227 "./data/applications/kde4/soundkonverter.desktop")200 "./data/applications/kde4/soundkonverter.desktop")
201
202 def test_purchase_via_software_center_agent(self):
228 # test the for-purchase case (uses "software-center-agent" as its203 # test the for-purchase case (uses "software-center-agent" as its
229 # appdetails.desktop_file value)204 # appdetails.desktop_file value)
230 # FIXME: this will only work if update-manager is installed205 # FIXME: this will only work if update-manager is installed
@@ -233,6 +208,8 @@
233 app_install_desktop_path, "update-manager")208 app_install_desktop_path, "update-manager")
234 self.assertEqual(installed_desktop_path,209 self.assertEqual(installed_desktop_path,
235 "/usr/share/applications/update-manager.desktop")210 "/usr/share/applications/update-manager.desktop")
211
212 def test_no_value(self):
236 # test case where we don't have a value for app_install_desktop_path213 # test case where we don't have a value for app_install_desktop_path
237 # (e.g. for a local .deb install, see bug LP: #768158)214 # (e.g. for a local .deb install, see bug LP: #768158)
238 installed_desktop_path = convert_desktop_file_to_installed_location(215 installed_desktop_path = convert_desktop_file_to_installed_location(

Subscribers

People subscribed via source and target branches

to all changes: