Merge lp:~elopio/ubuntu-system-settings-online-accounts/launch_fixture into lp:ubuntu-system-settings-online-accounts

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/ubuntu-system-settings-online-accounts/launch_fixture
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 115 lines (+61/-26)
2 files modified
tests/autopilot/online_accounts_ui/fixture_setup.py (+57/-0)
tests/autopilot/online_accounts_ui/tests/__init__.py (+4/-26)
To merge this branch: bzr merge lp:~elopio/ubuntu-system-settings-online-accounts/launch_fixture
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Víctor R. Ruiz (community) Needs Fixing
Online Accounts Pending
Review via email: mp+226498@code.launchpad.net

This proposal has been superseded by a proposal from 2014-07-15.

Commit message

Moved the launcher to a fixture so it can be reused outside of the testcase.

To post a comment you must log in.
Revision history for this message
Víctor R. Ruiz (vrruiz) wrote :

Overall, looks good to me. Needs fixing: Classes and methods need docstrings. And the name of the class (LaunchBinaryOnlineAccountsUI) conflicts with the one used in /tests/__init__.py (LaunchOnlineAccountsUI).

review: Needs Fixing
136. By Leo Arias

Added a comment.

137. By Leo Arias

Added a comment.

138. By Leo Arias

Fixed the online accounts ui fixture name.

Revision history for this message
Leo Arias (elopio) wrote :

> Overall, looks good to me. Needs fixing: Classes and methods need docstrings.

Added.

> And the name of the class (LaunchBinaryOnlineAccountsUI) conflicts with the
> one used in /tests/__init__.py (LaunchOnlineAccountsUI).

Good catch, I forgot to update it there.

Thanks.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

138. By Leo Arias

Fixed the online accounts ui fixture name.

137. By Leo Arias

Added a comment.

136. By Leo Arias

Added a comment.

135. By Leo Arias

Moved the launcher to a fixture so it can be reused outside of the testcase.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/autopilot/online_accounts_ui/fixture_setup.py'
2--- tests/autopilot/online_accounts_ui/fixture_setup.py 1970-01-01 00:00:00 +0000
3+++ tests/autopilot/online_accounts_ui/fixture_setup.py 2014-07-11 17:55:32 +0000
4@@ -0,0 +1,57 @@
5+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6+#
7+# Copyright (C) 2014 Canonical Ltd.
8+#
9+# This file is part of ubuntu-system-settings-online-accounts.
10+#
11+# ubuntu-system-settings-online-accounts is free software: you can
12+# redistribute it and/or modify it under the terms of the GNU General Public
13+# License as published by the Free Software Foundation; version 3.
14+#
15+# ubuntu-system-settings-online-accounts is distributed in the hope that it
16+# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+import subprocess
24+import time
25+
26+import fixtures
27+import ubuntuuitoolkit
28+from autopilot import application
29+
30+
31+class LaunchBinaryOnlineAccountsUI(fixtures.Fixture):
32+
33+ """Fixture to launch the Online Accounts UI using the installed binary."""
34+
35+ def setUp(self):
36+ """Launch the application when the fixture is used."""
37+ super().setUp()
38+ self.application_proxy = self._launch_application()
39+
40+ def _launch_application(self):
41+ # Increase the timeout of online-accounts-ui, to make sure it won't
42+ # quit before the system settings panel asks it to open.
43+ self.useFixture(
44+ fixtures.EnvironmentVariable('OAU_DAEMON_TIMEOUT', '120'))
45+ base_class = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
46+ application_launcher = self.useFixture(
47+ application.NormalApplicationLauncher(
48+ emulator_base=base_class)
49+ )
50+ application_proxy = application_launcher.launch(
51+ 'online-accounts-ui',
52+ '--desktop_file_hint='
53+ '/usr/share/applications/online-accounts-ui.desktop',
54+ app_type='qt', capture_output=True)
55+ system_settings = subprocess.Popen(
56+ ['system-settings', 'online-accounts',
57+ '--desktop_file_hint='
58+ '/usr/share/applications/ubuntu-system-settings.desktop'])
59+ self.addCleanup(system_settings.terminate)
60+ time.sleep(1)
61+ return application_proxy
62
63=== modified file 'tests/autopilot/online_accounts_ui/tests/__init__.py'
64--- tests/autopilot/online_accounts_ui/tests/__init__.py 2014-07-03 08:17:37 +0000
65+++ tests/autopilot/online_accounts_ui/tests/__init__.py 2014-07-11 17:55:32 +0000
66@@ -16,16 +16,13 @@
67 # You should have received a copy of the GNU General Public License
68 # along with this program. If not, see <http://www.gnu.org/licenses/>.
69
70-import fixtures
71-import subprocess
72-import time
73-
74 import ubuntuuitoolkit
75 from autopilot import platform
76 from autopilot.matchers import Eventually
77 from testtools.matchers import Equals
78
79 import online_accounts_ui
80+from online_accounts_ui import fixture_setup
81
82
83 class BaseOnlineAccountsUITestCase(
84@@ -37,28 +34,9 @@
85 if platform.model() != 'Desktop':
86 self.skipTest('Skip because of bug http://pad.lv/1252294')
87
88- application_proxy = self.launch_application()
89+ launch_application = fixture_setup.LaunchBinaryOnlineAccountsUI()
90+ self.useFixture(launch_application)
91 self.application = online_accounts_ui.OnlineAccountsUI(
92- application_proxy)
93+ launch_application.application_proxy)
94 self.assertThat(
95 self.application.main_view.visible, Eventually(Equals(True)))
96-
97- def launch_application(self):
98- # Increase the timeout of online-accounts-ui, to make sure it won't
99- # quit before the system settings panel asks it to open.
100- self.useFixture(
101- fixtures.EnvironmentVariable('OAU_DAEMON_TIMEOUT', '120'))
102- application = self.launch_test_application(
103- 'online-accounts-ui',
104- '--desktop_file_hint='
105- '/usr/share/applications/online-accounts-ui.desktop',
106- app_type='qt',
107- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase,
108- capture_output=True)
109- system_settings = subprocess.Popen(
110- ['system-settings', 'online-accounts',
111- '--desktop_file_hint='
112- '/usr/share/applications/ubuntu-system-settings.desktop'])
113- self.addCleanup(system_settings.terminate)
114- time.sleep(1)
115- return application

Subscribers

People subscribed via source and target branches