Merge lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes into lp:autopilot/1.3

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 332
Merged at revision: 332
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes
Merge into: lp:autopilot/1.3
Diff against target: 147 lines (+9/-68)
2 files modified
autopilot/introspection/dbus.py (+2/-39)
autopilot/tests/functional/test_dbus_query.py (+7/-29)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Leo Arias (community) code review. Approve
Autopilot Hackers Pending
Review via email: mp+186086@code.launchpad.net

Commit message

Back out changes that would break test case compatibility.

Description of the change

This branch removes the changes that makes autopilot incompatible with test cases. Namely, it removes the following:

 * Addition of the wait_select_single method.
 * Change to make select-single raise a StateNotFound error instead of returning None.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Sad, but sane. Thanks.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/introspection/dbus.py'
--- autopilot/introspection/dbus.py 2013-09-16 15:22:01 +0000
+++ autopilot/introspection/dbus.py 2013-09-17 15:59:21 +0000
@@ -168,7 +168,6 @@
168 self.__refresh_on_attribute = True168 self.__refresh_on_attribute = True
169 self._set_properties(state_dict)169 self._set_properties(state_dict)
170 self._path = path170 self._path = path
171 self._poll_time = 10
172171
173 def _set_properties(self, state_dict):172 def _set_properties(self, state_dict):
174 """Creates and set attributes of *self* based on contents of173 """Creates and set attributes of *self* based on contents of
@@ -360,8 +359,7 @@
360 app.select_single('QPushButton', objectName='clickme')359 app.select_single('QPushButton', objectName='clickme')
361 # returns a QPushButton whose 'objectName' property is 'clickme'.360 # returns a QPushButton whose 'objectName' property is 'clickme'.
362361
363 If nothing is returned from the query, this method raises362 If nothing is returned from the query, this method returns None.
364 StateNotFoundError.
365363
366 :param type_name: Either a string naming the type you want, or a class364 :param type_name: Either a string naming the type you want, or a class
367 of the appropriate type (the latter case is for overridden emulator365 of the appropriate type (the latter case is for overridden emulator
@@ -373,8 +371,6 @@
373 :raises TypeError: if neither *type_name* or keyword filters are371 :raises TypeError: if neither *type_name* or keyword filters are
374 provided.372 provided.
375373
376 :raises StateNotFoundError: if the requested object was not found.
377
378 .. seealso::374 .. seealso::
379 Tutorial Section :ref:`custom_emulators`375 Tutorial Section :ref:`custom_emulators`
380376
@@ -383,42 +379,9 @@
383 if len(instances) > 1:379 if len(instances) > 1:
384 raise ValueError("More than one item was returned for query")380 raise ValueError("More than one item was returned for query")
385 if not instances:381 if not instances:
386 raise StateNotFoundError(type_name, **kwargs)382 return None
387 return instances[0]383 return instances[0]
388384
389 def wait_select_single(self, type_name='*', **kwargs):
390 """Does the same thing as :meth:`select_single`, but will poll the
391 application continually until a valid object is found. This is useful
392 in situations where the object you are trying to select may not exist
393 yet.
394
395 After 10 seconds, a StateNotFoundError will be raised, as if the
396 :meth:`select_single` method had been called instead.
397
398 :param type_name: Either a string naming the type you want, or a class
399 of the appropriate type (the latter case is for overridden emulator
400 classes).
401
402 :raises ValueError: if the query returns more than one item. *If
403 you want more than one item, use select_many instead*.
404
405 :raises TypeError: if neither *type_name* or keyword filters are
406 provided.
407
408 :raises StateNotFoundError: if the requested object was not found.
409
410 .. seealso::
411 Tutorial Section :ref:`custom_emulators`
412
413 """
414 for i in range(self._poll_time):
415 try:
416 return self.select_single(type_name, **kwargs)
417 except StateNotFoundError:
418 if i == self._poll_time - 1:
419 raise
420 sleep(1)
421
422 def select_many(self, type_name='*', **kwargs):385 def select_many(self, type_name='*', **kwargs):
423 """Get a list of nodes from the introspection tree, with type equal to386 """Get a list of nodes from the introspection tree, with type equal to
424 *type_name* and (optionally) matching the keyword filters present in387 *type_name* and (optionally) matching the keyword filters present in
425388
=== modified file 'autopilot/tests/functional/test_dbus_query.py'
--- autopilot/tests/functional/test_dbus_query.py 2013-09-16 13:02:23 +0000
+++ autopilot/tests/functional/test_dbus_query.py 2013-09-17 15:59:21 +0000
@@ -22,12 +22,10 @@
22import os22import os
23import subprocess23import subprocess
24import signal24import signal
25from time import time
26from tempfile import mktemp25from tempfile import mktemp
2726
28from autopilot.testcase import AutopilotTestCase27from autopilot.testcase import AutopilotTestCase
29from testtools.matchers import Equals, NotEquals, raises, LessThan, GreaterThan28from testtools.matchers import Equals, NotEquals, raises
30from autopilot.introspection.dbus import StateNotFoundError
3129
3230
33class DbusQueryTests(AutopilotTestCase):31class DbusQueryTests(AutopilotTestCase):
@@ -128,10 +126,10 @@
128 fn = lambda: app.select_single()126 fn = lambda: app.select_single()
129 self.assertThat(fn, raises(TypeError))127 self.assertThat(fn, raises(TypeError))
130128
131 def test_select_single_no_match_raises_exception(self):129 def test_select_single_no_match_returns_none(self):
132 app = self.start_fully_featured_app()130 app = self.start_fully_featured_app()
133 match_fn = lambda: app.select_single("QMadeupType")131 failed_match = app.select_single("QMadeupType")
134 self.assertThat(match_fn, raises(StateNotFoundError('QMadeupType')))132 self.assertThat(failed_match, Equals(None))
135133
136 def test_select_single_parameters_only(self):134 def test_select_single_parameters_only(self):
137 app = self.start_fully_featured_app()135 app = self.start_fully_featured_app()
@@ -140,13 +138,10 @@
140 self.assertThat(titled_help, NotEquals(None))138 self.assertThat(titled_help, NotEquals(None))
141 self.assertThat(titled_help.title, Equals('Help'))139 self.assertThat(titled_help.title, Equals('Help'))
142140
143 def test_select_single_parameters_no_match_raises_exception(self):141 def test_select_single_parameters_no_match_returns_none(self):
144 app = self.start_fully_featured_app()142 app = self.start_fully_featured_app()
145 match_fn = lambda: app.select_single(title="Non-existant object")143 failed_match = app.select_single(title="Non-existant object")
146 self.assertThat(144 self.assertThat(failed_match, Equals(None))
147 match_fn,
148 raises(StateNotFoundError(title="Non-existant object"))
149 )
150145
151 def test_select_single_returning_multiple_raises(self):146 def test_select_single_returning_multiple_raises(self):
152 app = self.start_fully_featured_app()147 app = self.start_fully_featured_app()
@@ -168,23 +163,6 @@
168 failed_match = app.select_many('QMenu', title='qwerty')163 failed_match = app.select_many('QMenu', title='qwerty')
169 self.assertThat(failed_match, Equals([]))164 self.assertThat(failed_match, Equals([]))
170165
171 def test_wait_select_single_succeeds_quickly(self):
172 app = self.start_fully_featured_app()
173 start_time = time()
174 main_window = app.wait_select_single('QMainWindow')
175 end_time = time()
176 self.assertThat(main_window, NotEquals(None))
177 self.assertThat(abs(end_time - start_time), LessThan(1))
178
179 def test_wait_select_single_fails_slowly(self):
180 app = self.start_fully_featured_app()
181 start_time = time()
182 fn = lambda: app.wait_select_single('QMadeupType')
183 self.assertThat(fn, raises(StateNotFoundError('QMadeupType')))
184 end_time = time()
185 self.assertThat(abs(end_time - start_time), GreaterThan(9))
186 self.assertThat(abs(end_time - start_time), LessThan(11))
187
188166
189class DbusCustomBusTests(AutopilotTestCase):167class DbusCustomBusTests(AutopilotTestCase):
190 """Test the ability to use custom dbus buses during a test."""168 """Test the ability to use custom dbus buses during a test."""

Subscribers

People subscribed via source and target branches

to all changes: