Merge lp:~autopilot/autopilot/temp-dev into lp:autopilot

Proposed by Christopher Lee
Status: Merged
Merged at revision: 492
Proposed branch: lp:~autopilot/autopilot/temp-dev
Merge into: lp:autopilot
Diff against target: 291 lines (+89/-47)
7 files modified
autopilot/application/_launcher.py (+1/-0)
autopilot/exceptions.py (+13/-12)
autopilot/tests/unit/test_application_launcher.py (+14/-0)
autopilot/tests/unit/test_exceptions.py (+26/-20)
autopilot/tests/unit/test_introspection_dbus.py (+3/-1)
autopilot/tests/unit/test_types.py (+31/-13)
docs/conf.py (+1/-1)
To merge this branch: bzr merge lp:~autopilot/autopilot/temp-dev
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Autopilot Hackers Pending
Review via email: mp+223011@code.launchpad.net

Commit message

Fix DateTime tests that failed due to recent DateTime changes that removed assumption of UTC TZ. Fixes: https://bugs.launchpad.net/bugs/1324441.
Set process on proxy object when launched via fixture (LP:1327377). Fixes: https://bugs.launchpad.net/bugs/1327377.
Add link to url troubleshooting guide when state not found error is raise.
Update docs version number in sphinx config.
Update Apparmor rules.

Description of the change

Fix DateTime tests that failed due to recent DateTime changes that removed assumption of UTC TZ. Fixes: https://bugs.launchpad.net/bugs/1324441.
Set process on proxy object when launched via fixture (LP:1327377). Fixes: https://bugs.launchpad.net/bugs/1327377.
Add link to url troubleshooting guide when state not found error is raise.
Update docs version number in sphinx config.
Update Apparmor rules.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:523
http://jenkins.qa.ubuntu.com/job/autopilot-ci/743/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/17
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-amd64-ci/17/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/17
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-armhf-ci/17/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/17
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-utopic-i386-ci/17/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-autopilot/140
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic-touch/166/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic-autopilot/229
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/918
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/918/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1580
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1580/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6814/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8418

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/autopilot-ci/743/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/application/_launcher.py'
2--- autopilot/application/_launcher.py 2014-05-29 16:43:08 +0000
3+++ autopilot/application/_launcher.py 2014-06-13 00:22:23 +0000
4@@ -379,6 +379,7 @@
5 process=process,
6 pid=process.pid
7 )
8+ proxy_object.set_process(process)
9 return proxy_object
10
11 def _setup_environment(self, app_path, app_type, arguments):
12
13=== modified file 'autopilot/exceptions.py'
14--- autopilot/exceptions.py 2014-05-21 07:39:59 +0000
15+++ autopilot/exceptions.py 2014-06-13 00:22:23 +0000
16@@ -26,11 +26,8 @@
17
18 """
19
20-import six
21-
22
23 class BackendException(RuntimeError):
24-
25 """An error occured while trying to initialise an autopilot backend."""
26
27 def __init__(self, original_exception):
28@@ -63,7 +60,6 @@
29 application.
30
31 """
32-
33 def __init__(self, class_name=None, **filters):
34 """Construct a StateNotFoundError.
35
36@@ -71,13 +67,14 @@
37 are specified.
38
39 """
40+
41 if class_name is None and not filters:
42 raise ValueError("Must specify either class name or filters.")
43
44 if class_name is None:
45 self._message = \
46 u"Object not found with properties {}.".format(
47- repr(filters)
48+ repr(filters),
49 )
50 elif not filters:
51 self._message = u"Object not found with name '{}'.".format(
52@@ -90,14 +87,18 @@
53 repr(filters)
54 )
55
56+ _troubleshoot_url_message = (
57+ 'Tips on minimizing the occurrence of this failure'
58+ 'are available here: '
59+ 'http://developer.ubuntu.com/api/devel/ubuntu-14.10/python/'
60+ 'autopilot/faq/troubleshooting.html'
61+ )
62+
63 def __str__(self):
64- if six.PY3:
65- return self._message
66- else:
67- return self._message.encode('utf8')
68-
69- def __unicode__(self):
70- return self._message
71+ return '{}\n\n{}'.format(
72+ self._message,
73+ self._troubleshoot_url_message
74+ )
75
76
77 class InvalidXPathQuery(ValueError):
78
79=== modified file 'autopilot/tests/unit/test_application_launcher.py'
80--- autopilot/tests/unit/test_application_launcher.py 2014-05-29 16:43:08 +0000
81+++ autopilot/tests/unit/test_application_launcher.py 2014-06-13 00:22:23 +0000
82@@ -213,6 +213,20 @@
83 @patch('autopilot.application._launcher.'
84 'get_proxy_object_for_existing_process')
85 @patch('autopilot.application._launcher._get_application_path')
86+ def test_launch_sets_process_of_proxy_object(self, _, gpofep):
87+ """Test that NormalApplicationLauncher.launch returns the proxy object
88+ returned by get_proxy_object_for_existing_process."""
89+ launcher = NormalApplicationLauncher()
90+ with patch.object(launcher, '_launch_application_process') as lap:
91+ with patch.object(launcher, '_setup_environment') as se:
92+ se.return_value = ('', [])
93+ launcher.launch('')
94+ set_process = gpofep.return_value.set_process
95+ set_process.assert_called_once_with(lap.return_value)
96+
97+ @patch('autopilot.application._launcher.'
98+ 'get_proxy_object_for_existing_process')
99+ @patch('autopilot.application._launcher._get_application_path')
100 def test_launch_returns_proxy_object(self, _, gpofep):
101 """Test that NormalApplicationLauncher.launch returns the proxy object
102 returned by get_proxy_object_for_existing_process."""
103
104=== modified file 'autopilot/tests/unit/test_exceptions.py'
105--- autopilot/tests/unit/test_exceptions.py 2014-04-15 02:32:16 +0000
106+++ autopilot/tests/unit/test_exceptions.py 2014-06-13 00:22:23 +0000
107@@ -17,9 +17,8 @@
108 # along with this program. If not, see <http://www.gnu.org/licenses/>.
109 #
110
111-import six
112 from testtools import TestCase
113-from testtools.matchers import raises, Equals
114+from testtools.matchers import raises, EndsWith, Equals
115
116 from autopilot.exceptions import StateNotFoundError
117
118@@ -41,26 +40,23 @@
119 err = StateNotFoundError("MyClass")
120 self.assertThat(
121 str(err),
122- Equals("Object not found with name 'MyClass'.")
123+ Equals("Object not found with name 'MyClass'.\n\n{}".format(
124+ StateNotFoundError._troubleshoot_url_message
125+ ))
126 )
127- if not six.PY3:
128- self.assertThat(
129- unicode(err),
130- Equals(u"Object not found with name 'MyClass'.")
131- )
132
133 def test_can_be_constructed_with_filters_only(self):
134 """Must be able to construct exception with filters only."""
135 err = StateNotFoundError(foo="bar")
136 self.assertThat(
137 str(err),
138- Equals("Object not found with properties {'foo': 'bar'}.")
139+ Equals(
140+ "Object not found with properties {}."
141+ "\n\n{}".format(
142+ "{'foo': 'bar'}",
143+ StateNotFoundError._troubleshoot_url_message
144+ ))
145 )
146- if not six.PY3:
147- self.assertThat(
148- unicode(err),
149- Equals(u"Object not found with properties {'foo': 'bar'}.")
150- )
151
152 def test_can_be_constructed_with_class_name_and_filters(self):
153 """Must be able to construct with both class name and filters."""
154@@ -68,11 +64,21 @@
155 self.assertThat(
156 str(err),
157 Equals("Object not found with name 'MyClass'"
158- " and properties {'foo': 'bar'}.")
159+ " and properties {}.\n\n{}".format(
160+ "{'foo': 'bar'}",
161+ StateNotFoundError._troubleshoot_url_message
162+ ))
163 )
164- if not six.PY3:
165- self.assertThat(
166- unicode(err),
167- Equals(u"Object not found with name 'MyClass'"
168- " and properties {'foo': 'bar'}.")
169+
170+ def test_StateNotFoundError_endswith_troubleshoot_url_message_text(self):
171+ """The assertion raised must end with a link to troubleshooting url."""
172+ err = StateNotFoundError('MyClass', foo="bar")
173+ self.assertThat(
174+ str(err),
175+ EndsWith(
176+ 'Tips on minimizing the occurrence of this failure'
177+ 'are available here: '
178+ 'http://developer.ubuntu.com/api/devel/ubuntu-14.10/python/'
179+ 'autopilot/faq/troubleshooting.html'
180 )
181+ )
182
183=== modified file 'autopilot/tests/unit/test_introspection_dbus.py'
184--- autopilot/tests/unit/test_introspection_dbus.py 2014-05-20 08:53:21 +0000
185+++ autopilot/tests/unit/test_introspection_dbus.py 2014-06-13 00:22:23 +0000
186@@ -171,7 +171,9 @@
187 path: '/some/path'
188 text: 'Hello'
189 Error: Object not found with name 'child'.
190- """))
191+
192+ {}
193+ """.format(StateNotFoundError._troubleshoot_url_message)))
194
195 def test_print_tree_fileobj(self):
196 """print_tree with file object output"""
197
198=== modified file 'autopilot/tests/unit/test_types.py'
199--- autopilot/tests/unit/test_types.py 2014-05-20 08:53:21 +0000
200+++ autopilot/tests/unit/test_types.py 2014-06-13 00:22:23 +0000
201@@ -19,13 +19,14 @@
202
203 from __future__ import absolute_import
204
205+import dbus
206+import six
207+
208 from datetime import datetime, time
209-from unittest.mock import patch, Mock
210-import six
211 from testscenarios import TestWithScenarios
212 from testtools import TestCase
213 from testtools.matchers import Equals, IsInstance, NotEquals, raises
214-import dbus
215+from unittest.mock import patch, Mock
216
217 from autopilot.introspection.types import (
218 Color,
219@@ -307,13 +308,25 @@
220 def test_datetime_has_properties(self):
221 dt = DateTime(1377209927)
222
223- self.assertThat(dt.timestamp, Equals(1377209927))
224- self.assertThat(dt.year, Equals(2013))
225- self.assertThat(dt.month, Equals(8))
226- self.assertThat(dt.day, Equals(22))
227- self.assertThat(dt.hour, Equals(22))
228- self.assertThat(dt.minute, Equals(18))
229- self.assertThat(dt.second, Equals(47))
230+ self.assertTrue(hasattr(dt, 'timestamp'))
231+ self.assertTrue(hasattr(dt, 'year'))
232+ self.assertTrue(hasattr(dt, 'month'))
233+ self.assertTrue(hasattr(dt, 'day'))
234+ self.assertTrue(hasattr(dt, 'hour'))
235+ self.assertTrue(hasattr(dt, 'minute'))
236+ self.assertTrue(hasattr(dt, 'second'))
237+
238+ def test_datetime_properties_have_correct_values(self):
239+ dt = DateTime(1377209927)
240+ dt_with_tz = datetime.fromtimestamp(1377209927)
241+
242+ self.assertThat(dt.timestamp, Equals(dt_with_tz.timestamp()))
243+ self.assertThat(dt.year, Equals(dt_with_tz.year))
244+ self.assertThat(dt.month, Equals(dt_with_tz.month))
245+ self.assertThat(dt.day, Equals(dt_with_tz.day))
246+ self.assertThat(dt.hour, Equals(dt_with_tz.hour))
247+ self.assertThat(dt.minute, Equals(dt_with_tz.minute))
248+ self.assertThat(dt.second, Equals(dt_with_tz.second))
249
250 def test_equality_with_datetime(self):
251 dt1 = DateTime(1377209927)
252@@ -328,9 +341,10 @@
253 self.assertThat(dt1, Equals(dt2))
254
255 def test_equality_with_datetime_timestamp(self):
256+ # DateTime no longer assumes UTC and uses local TZ.
257 dt1 = DateTime(1377209927)
258- dt2 = datetime.utcfromtimestamp(1377209927)
259- dt3 = datetime.utcfromtimestamp(1377209928)
260+ dt2 = datetime.fromtimestamp(1377209927)
261+ dt3 = datetime.fromtimestamp(1377209928)
262
263 self.assertThat(dt1, Equals(dt2))
264 self.assertThat(dt1, NotEquals(dt3))
265@@ -341,8 +355,12 @@
266 self.assertThat(dt1.datetime, IsInstance(datetime))
267
268 def test_repr(self):
269+ expected = repr_type(
270+ u"DateTime({:%Y-%m-%d %H:%M:%S})".format(
271+ datetime.fromtimestamp(1377209927)
272+ )
273+ )
274 dt = DateTime(1377209927)
275- expected = repr_type('DateTime(2013-08-22 22:18:47)')
276 observed = repr(dt)
277 self.assertEqual(expected, observed)
278
279
280=== modified file 'docs/conf.py'
281--- docs/conf.py 2014-04-30 21:39:57 +0000
282+++ docs/conf.py 2014-06-13 00:22:23 +0000
283@@ -75,7 +75,7 @@
284 # built documents.
285 #
286 # The short X.Y version.
287-version = '1.4'
288+version = '1.5'
289
290 # The full version, including alpha/beta/rc tags.
291 try:

Subscribers

People subscribed via source and target branches