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
1=== modified file 'test/gtk3/test_unity_launcher_integration.py'
2--- test/gtk3/test_unity_launcher_integration.py 2012-07-18 15:12:20 +0000
3+++ test/gtk3/test_unity_launcher_integration.py 2012-07-18 15:26:24 +0000
4@@ -109,8 +109,8 @@
5 "")
6 self._install_from_list_view(test_pkgname)
7 self.assertTrue(mock_send_application_to_launcher.called)
8- args = mock_send_application_to_launcher.call_args
9- self._check_send_application_to_launcher_args(args[0][0], args[0][1])
10+ args, kwargs = mock_send_application_to_launcher.call_args
11+ self._check_send_application_to_launcher_args(*args, **kwargs)
12
13 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
14 '.send_application_to_launcher')
15@@ -128,8 +128,8 @@
16 "")
17 self._navigate_to_appdetails_and_install(test_pkgname)
18 self.assertTrue(mock_send_application_to_launcher.called)
19- args = mock_send_application_to_launcher.call_args
20- self._check_send_application_to_launcher_args(args[0][0], args[0][1])
21+ args, kwargs = mock_send_application_to_launcher.call_args
22+ self._check_send_application_to_launcher_args(*args, **kwargs)
23
24 @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
25 '.send_application_to_launcher')
26@@ -140,76 +140,47 @@
27 test_pkgname = "software-center"
28 self._navigate_to_appdetails_and_install(test_pkgname)
29 self.assertFalse(mock_send_application_to_launcher.called)
30-
31- @patch('softwarecenter.ui.gtk3.panes.availablepane'
32- '.convert_desktop_file_to_installed_location')
33- @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
34- '.send_application_to_launcher')
35- # NOTE: the order of attributes in the method call appears reversed, this
36- # is because the patch decorators above are executed from innermost to
37- # outermost
38- def test_unity_launcher_integration_launcher_displayed_app(self,
39- mock_send_application_to_launcher,
40- mock_convert_desktop_file_to_installed_location):
41- # test that the add to launcher call is made in the case where
42- # an application with a valid and displayable desktop file
43- available_pane.add_to_launcher_enabled = True
44- test_pkgname = "software-center"
45- app_install_desktop_file_path = ("/usr/share/app-install/desktop/"
46- "software-center:ubuntu-software-center.desktop")
47- mock_convert_desktop_file_to_installed_location.return_value = (
48- app_install_desktop_file_path)
49- self._navigate_to_appdetails_and_install(test_pkgname)
50- # make sure that the add to launcher call is made
51- self.assertTrue(mock_send_application_to_launcher.called)
52-
53- @patch('softwarecenter.ui.gtk3.panes.availablepane'
54- '.convert_desktop_file_to_installed_location')
55- @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
56- '.send_application_to_launcher')
57- # NOTE: the order of attributes in the method call appears reversed, this
58- # is because the patch decorators above are executed from innermost to
59- # outermost
60- def test_unity_launcher_integration_no_display_in_desktop_file(self,
61- mock_send_application_to_launcher,
62- mock_convert_desktop_file_to_installed_location):
63- # test that the add to launcher call is *not* made in the case where
64- # an application's desktop file specifies "NoDisplay=true"
65- available_pane.add_to_launcher_enabled = True
66- test_pkgname = "wine"
67- app_install_desktop_file_path = ("/usr/share/app-install/desktop/"
68- "wine1.4:wine.desktop")
69- mock_convert_desktop_file_to_installed_location.return_value = (
70- app_install_desktop_file_path)
71- self._navigate_to_appdetails_and_install(test_pkgname)
72- # make sure that the add to launcher call is *not* made in the case
73- # where the desktop file specifies NoDisplay=True
74- self.assertFalse(mock_send_application_to_launcher.called)
75-
76- @patch('softwarecenter.ui.gtk3.panes.availablepane'
77- '.convert_desktop_file_to_installed_location')
78- @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
79- '.send_application_to_launcher')
80- # NOTE: the order of attributes in the method call appears reversed, this
81- # is because the patch decorators above are executed from innermost to
82- # outermost
83- def test_unity_launcher_integration_no_exec_in_desktop_file(self,
84- mock_send_application_to_launcher,
85- mock_convert_desktop_file_to_installed_location):
86- # test that the add to launcher call is *not* made in the case where
87- # an application's desktop file does not contain an "exec" entry
88- available_pane.add_to_launcher_enabled = True
89- test_pkgname = "bzr"
90- app_install_desktop_file_path = ("/usr/share/app-install/desktop/"
91- "bzr.desktop")
92- mock_convert_desktop_file_to_installed_location.return_value = (
93- app_install_desktop_file_path)
94- self._navigate_to_appdetails_and_install(test_pkgname)
95- # make sure that the add to launcher call is *not* made in the case
96- # where the desktop file does not contain an "exec" entry
97- self.assertFalse(mock_send_application_to_launcher.called)
98-
99- def test_desktop_file_path_conversion(self):
100+
101+ @patch('softwarecenter.ui.gtk3.panes.availablepane'
102+ '.convert_desktop_file_to_installed_location')
103+ @patch('softwarecenter.ui.gtk3.panes.availablepane.UnityLauncher'
104+ '.send_application_to_launcher')
105+ # NOTE: the order of attributes in the method call appears reversed, this
106+ # is because the patch decorators above are executed from innermost to
107+ # outermost
108+ def test_unity_launcher_integration_launcher(self,
109+ mock_send_application_to_launcher,
110+ mock_convert_desktop_file_to_installed_location):
111+ # this is a 3-tuple of (pkgname, desktop-file, expected_result)
112+ TEST_CASES = (
113+ # normal app
114+ ("software-center", "/usr/share/app-install/desktop/"\
115+ "software-center:ubuntu-software-center.desktop", True),
116+ # NoDisplay=True line
117+ ("wine", "/usr/share/app-install/desktop/"\
118+ "wine1.4:wine.desktop", False),
119+ # No Exec= line
120+ ("bzr", "/usr/share/app-install/desktop/"\
121+ "bzr.desktop", False)
122+ )
123+ # run the test over all test-cases
124+ available_pane.add_to_launcher_enabled = True
125+ for test_pkgname, app_install_desktop_file_path, res in TEST_CASES:
126+ # setup the mock
127+ mock_convert_desktop_file_to_installed_location.return_value = (
128+ app_install_desktop_file_path)
129+ # this is the tofu of the test
130+ self._navigate_to_appdetails_and_install(test_pkgname)
131+ # verify
132+ self.assertEqual(mock_send_application_to_launcher.called, res)
133+ # and reset again to ensure we don't get the call info from
134+ # the previous call(s)
135+ mock_send_application_to_launcher.reset_mock()
136+
137+
138+class DesktopFilepathConversionTestCase(unittest.TestCase):
139+
140+ def test_normal(self):
141 # test 'normal' case
142 app_install_desktop_path = ("./data/app-install/desktop/" +
143 "deja-dup:deja-dup.desktop")
144@@ -217,6 +188,8 @@
145 app_install_desktop_path, "deja-dup")
146 self.assertEqual(installed_desktop_path,
147 "./data/applications/deja-dup.desktop")
148+
149+ def test_encoded_subdir(self):
150 # test encoded subdirectory case, e.g. e.g. kde4_soundkonverter.desktop
151 app_install_desktop_path = ("./data/app-install/desktop/" +
152 "soundkonverter:" +
153@@ -225,6 +198,8 @@
154 app_install_desktop_path, "soundkonverter")
155 self.assertEqual(installed_desktop_path,
156 "./data/applications/kde4/soundkonverter.desktop")
157+
158+ def test_purchase_via_software_center_agent(self):
159 # test the for-purchase case (uses "software-center-agent" as its
160 # appdetails.desktop_file value)
161 # FIXME: this will only work if update-manager is installed
162@@ -233,6 +208,8 @@
163 app_install_desktop_path, "update-manager")
164 self.assertEqual(installed_desktop_path,
165 "/usr/share/applications/update-manager.desktop")
166+
167+ def test_no_value(self):
168 # test case where we don't have a value for app_install_desktop_path
169 # (e.g. for a local .deb install, see bug LP: #768158)
170 installed_desktop_path = convert_desktop_file_to_installed_location(

Subscribers

People subscribed via source and target branches

to all changes: