Merge lp:~elopio/ubuntu-ui-toolkit/fix1248570-autopilot_check into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Merged
Approved by: Cris Dywan
Approved revision: 825
Merged at revision: 824
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1248570-autopilot_check
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 87 lines (+42/-0)
2 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+16/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+26/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1248570-autopilot_check
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+194188@code.launchpad.net

Commit message

Add a check for the autopilot version on the emulator init.

To post a comment you must log in.
825. By Leo Arias

Fixed typo. Added autospec to prevent it in the future.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Nice!

It does still run through if the check fails resulting in 92 failures, which seems a little wasteful, but as it seems non-trivial to stop early let's leave it as-is. It's a clear failure unlike before which is what's important.

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

PASSED: Continuous integration, rev:825
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1170/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/532
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/520
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/118
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/118
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/118/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/491
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/532
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/532/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/520
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/520/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2988
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/3170
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1154
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/1153

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1170/rebuild

review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

See bug 1248634 for a feature request for autopilot to stop early.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
2--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-06 04:17:28 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-06 16:45:32 +0000
4@@ -15,7 +15,9 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6
7 import logging
8+from distutils import version
9
10+import autopilot
11 from autopilot import input, platform
12 from autopilot.introspection import dbus
13
14@@ -42,10 +44,24 @@
15 return input.Pointer(device=input_device_class.create())
16
17
18+def check_autopilot_version():
19+ """Check that the Autopilot installed version matches the one required.
20+
21+ :raise ToolkitEmulatorException: If the installed Autopilot version does't
22+ match the required by the emulators.
23+
24+ """
25+ installed_version = version.LooseVersion(autopilot.version)
26+ if installed_version < version.LooseVersion('1.4'):
27+ raise ToolkitEmulatorException(
28+ 'The emulators need Autopilot 1.4 or higher.')
29+
30+
31 class UbuntuUIToolkitEmulatorBase(dbus.CustomEmulatorBase):
32 """A base class for all the Ubuntu UI Toolkit emulators."""
33
34 def __init__(self, *args):
35+ check_autopilot_version()
36 super(UbuntuUIToolkitEmulatorBase, self).__init__(*args)
37 self.pointing_device = get_pointing_device()
38 # TODO it would be nice to have access to the screen keyboard if we are
39
40=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
41--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-06 04:17:28 +0000
42+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-06 16:45:32 +0000
43@@ -18,12 +18,30 @@
44 import time
45 import unittest
46
47+import autopilot
48 from autopilot import input, platform
49 from testtools.matchers import GreaterThan, LessThan
50
51 from ubuntuuitoolkit import emulators, tests
52
53
54+class CheckAutopilotVersionTestCase(unittest.TestCase):
55+
56+ def test_lower_version_should_raise_exception(self):
57+ with mock.patch.object(autopilot, 'version', '1.3'):
58+ self.assertRaises(
59+ emulators.ToolkitEmulatorException,
60+ emulators.check_autopilot_version)
61+
62+ def test_required_version_should_succeed(self):
63+ with mock.patch.object(autopilot, 'version', '1.4'):
64+ emulators.check_autopilot_version()
65+
66+ def test_higher_version_should_succeed(self):
67+ with mock.patch.object(autopilot, 'version', '1.5'):
68+ emulators.check_autopilot_version()
69+
70+
71 class UbuntuUIToolkitEmulatorBaseTestCase(tests.QMLStringAppTestCase):
72
73 def test_pointing_device(self):
74@@ -37,6 +55,14 @@
75 def test_pointing_device_in_phablet(self):
76 self.assertIsInstance(self.app.pointing_device._device, input.Touch)
77
78+ def test_emulators_should_check_version_on_init(self):
79+ check_name = 'ubuntuuitoolkit.emulators.check_autopilot_version'
80+ with mock.patch(check_name, autospec=True) as mock_check:
81+ # Instantiate any emulator.
82+ self.main_view
83+
84+ mock_check.assert_called_once_with()
85+
86
87 class MainViewTestCase(tests.QMLStringAppTestCase):
88

Subscribers

People subscribed via source and target branches

to status/vote changes: