Merge lp:~om26er/ubuntu-system-settings/pep8_pyflakes_fix into lp:ubuntu-system-settings

Proposed by Omer Akram
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 643
Merged at revision: 650
Proposed branch: lp:~om26er/ubuntu-system-settings/pep8_pyflakes_fix
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~laney/ubuntu-system-settings/migration-script-no-crash
Diff against target: 759 lines (+232/-121)
12 files modified
debian/control (+2/-0)
debian/rules (+3/-0)
debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py (+10/-4)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+43/-39)
tests/autopilot/ubuntu_system_settings/tests/test_about.py (+11/-6)
tests/autopilot/ubuntu_system_settings/tests/test_cellular.py (+19/-15)
tests/autopilot/ubuntu_system_settings/tests/test_datetime.py (+17/-10)
tests/autopilot/ubuntu_system_settings/tests/test_plugins.py (+69/-31)
tests/autopilot/ubuntu_system_settings/tests/test_search.py (+5/-7)
tests/autopilot/ubuntu_system_settings/tests/test_system_updates.py (+1/-6)
tests/autopilot/ubuntu_system_settings/utils/i18n.py (+5/-3)
tests/test_code.py (+47/-0)
To merge this branch: bzr merge lp:~om26er/ubuntu-system-settings/pep8_pyflakes_fix
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+210430@code.launchpad.net

This proposal supersedes a proposal from 2014-02-24.

Commit message

fix pep8 and pyflakes warning, our tests are now pep8 and pyflakes compliant.

Description of the change

fix pep8 and pyflakes warning, our tests are now pep8 and pyflakes compliant.

This branch is a prerequisite for more to come in a series to improve autopilot tests for ubuntu-system-settings

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

Finally \o/ -- Its read for review now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Thanks for the work there, nice job, some comments though:

- why do you drop the use of translations? some of us run non-english locales and it's important to be able to run the tests under those

- why those sort of changes

690 - """ Checks whether the Battery plugin is not available as we have no battery """
691 - self.assertThat(lambda: self.main_view.select_single(objectName='entryComponent-battery'),
692 - raises(StateNotFoundError))
693 + """ Checks whether the Battery plugin is not available as we
694 + have no battery
695 +
696 + """

the emtpy line at the end of the comment seems weird?

- could you add a test that runs pep8 and pyflake? so we can make sure we don't introduce new issues with futur commits

review: Needs Fixing
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

sorry for not replying, I am on vacation this week, will fix this MR when I
get back on Monday.

On Thu, Mar 6, 2014 at 4:55 PM, Sebastien Bacher <email address hidden> wrote:

> The proposal to merge lp:~om26er/ubuntu-system-settings/pep8_pyflakes_fix
> into lp:ubuntu-system-settings has been updated.
>
> Status: Needs review => Work in progress
>
> For more details, see:
>
> https://code.launchpad.net/~om26er/ubuntu-system-settings/pep8_pyflakes_fix/+merge/207966
> --
>
> https://code.launchpad.net/~om26er/ubuntu-system-settings/pep8_pyflakes_fix/+merge/207966
> You are the owner of lp:~om26er/ubuntu-system-settings/pep8_pyflakes_fix.
>

Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

> Thanks for the work there, nice job, some comments though:
>
Thanks for the review.

> - why do you drop the use of translations? some of us run non-english locales
> and it's important to be able to run the tests under those
>

In an optimal world we should not be testing labels in our apps because they are well tested in the UIToolkit, but in this case there are many places where we are testing label text which we should not be, My Further branches for system-settings will try and remove the reliability on labels as much as possible.

Instead of translating I am making sure that the app always loads en.US note:

35 + self.patch_environment('LC_MESSAGES', 'en_US.UTF-8')

> - why those sort of changes
>
> 690 - """ Checks whether the Battery plugin is not available as we have no
> battery """
> 691 - self.assertThat(lambda: self.main_view.select_single(objectName
> ='entryComponent-battery'),
> 692 - raises(StateNotFoundError))
> 693 + """ Checks whether the Battery plugin is not available as we
> 694 + have no battery
> 695 +
> 696 + """
>
> the emtpy line at the end of the comment seems weird?
>

Fixed that.

> - could you add a test that runs pep8 and pyflake? so we can make sure we
> don't introduce new issues with futur commits

Added two new tests to test both pyflakes and pep8, they currently are skipped if the related tool is not installed, do you think it makes sense for our suite to depend on pyflakes and pep8 ?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Looks good now, thanks!

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

FAILED: Continuous integration, rev:643
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~om26er/ubuntu-system-settings/pep8_pyflakes_fix/+merge/210430/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/694/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3828
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3413/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-amd64-ci/210
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-armhf-ci/198
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-i386-ci/197
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3359
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3846
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3846/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3415
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3415/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5776/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4677

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/694/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-03-03 17:03:21 +0000
3+++ debian/control 2014-03-11 15:00:54 +0000
4@@ -24,6 +24,8 @@
5 libapt-pkg-dev,
6 xvfb,
7 cmake,
8+ pep8,
9+ pyflakes,
10 Standards-Version: 3.9.4
11 Homepage: https://launchpad.net/ubuntu-system-settings
12 # If you aren't a member of ~system-settings-touch but need to upload packaging
13
14=== modified file 'debian/rules'
15--- debian/rules 2014-03-03 17:03:21 +0000
16+++ debian/rules 2014-03-11 15:00:54 +0000
17@@ -21,3 +21,6 @@
18
19 %:
20 dh $@ --fail-missing --with python2,migrations
21+
22+override_dh_auto_test:
23+ python tests/test_code.py
24
25=== modified file 'debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py'
26--- debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py 2014-03-11 15:00:53 +0000
27+++ debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py 2014-03-11 15:00:54 +0000
28@@ -20,7 +20,9 @@
29
30 # Migrate ubuntu-system-settings sound panel settings from GSettings to
31 # AccountsService
32-
33+
34+from __future__ import print_function
35+
36 import dbus
37 import os
38 import sys
39@@ -31,23 +33,27 @@
40 manager_proxy = system_bus.get_object('org.freedesktop.Accounts',
41 '/org/freedesktop/Accounts')
42 object_path = manager_proxy.FindUserById(
43- os.getuid(), dbus_interface='org.freedesktop.Accounts')
44+ os.getuid(), dbus_interface='org.freedesktop.Accounts'
45+)
46 user_proxy = system_bus.get_object('org.freedesktop.Accounts', object_path)
47
48 gsettings = Gio.Settings(schema="com.ubuntu.touch.sound")
49
50+
51 def get_string(key):
52 return gsettings.get_string(key)
53
54+
55 def get_bool(key):
56 return gsettings.get_boolean(key)
57
58+
59 def set_as_setting(interface, setting, value):
60 try:
61- user_proxy.Set(interface, setting, value,
62+ user_proxy.Set(interface, setting, value,
63 dbus_interface=dbus.PROPERTIES_IFACE)
64 except dbus.exceptions.DBusException as e:
65- print("Couldn't update %s: %s" % (setting, e), file=sys.stderr)
66+ print("Couldn't update %s: %s" % (setting, e), file=sys.stderr)
67
68 # (gsettings key, accountsservice key, function to retrieve from gsettings)
69 keys = [('silent-mode', 'SilentMode', get_bool),
70
71=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
72--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-02-18 15:42:24 +0000
73+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-03-11 15:00:54 +0000
74@@ -13,7 +13,6 @@
75
76 from autopilot.input import Mouse, Touch, Pointer
77 from autopilot.platform import model
78-from autopilot.testcase import AutopilotTestCase
79 from autopilot.matchers import Eventually
80 from testtools.matchers import Equals, NotEquals, GreaterThan
81
82@@ -25,12 +24,13 @@
83 import subprocess
84 from time import sleep
85
86+
87 class UbuntuSystemSettingsTestCase(UbuntuUIToolkitAppTestCase):
88 """ Base class for Ubuntu System Settings """
89 if model() == 'Desktop':
90- scenarios = [ ('with mouse', dict(input_device_class=Mouse)) ]
91+ scenarios = [('with mouse', dict(input_device_class=Mouse))]
92 else:
93- scenarios = [ ('with touch', dict(input_device_class=Touch)) ]
94+ scenarios = [('with touch', dict(input_device_class=Touch))]
95
96 def setUp(self, panel=None):
97 super(UbuntuSystemSettingsTestCase, self).setUp()
98@@ -40,7 +40,8 @@
99 def launch_system_settings(self, panel=None):
100 params = ['/usr/bin/system-settings']
101 if (model() != 'Desktop'):
102- params.append('--desktop_file_hint=/usr/share/applications/ubuntu-system-settings.desktop')
103+ params.append('--desktop_file_hint=/usr/share/applications/'
104+ 'ubuntu-system-settings.desktop')
105
106 # Launch to a specific panel
107 if panel is not None:
108@@ -69,8 +70,8 @@
109 page_center_x = int(page_right / 2)
110 page_center_y = int(page_bottom / 2)
111 while obj.globalRect[1] + obj.height > page_bottom:
112- self.pointer.drag(page_center_x, page_center_y,
113- page_center_x, page_center_y - obj.height * 2)
114+ self.pointer.drag(page_center_x, page_center_y,
115+ page_center_x, page_center_y - obj.height * 2)
116 # avoid a flick
117 sleep(0.5)
118
119@@ -96,7 +97,9 @@
120
121 def add_mock_battery(self):
122 """ Make sure we have a battery """
123- self.dbusmock.AddDischargingBattery('mock_BATTERY', 'Battery', 50.0, 10)
124+ self.dbusmock.AddDischargingBattery(
125+ 'mock_BATTERY', 'Battery', 50.0, 10
126+ )
127
128
129 class UbuntuSystemSettingsBatteryTestCase(UbuntuSystemSettingsUpowerTestCase):
130@@ -123,37 +126,39 @@
131 def setUp(self, panel=None):
132 self.obj_ofono.Reset()
133 # Add an available carrier
134- self.dbusmock.AddObject('/ril_0/operator/op2',
135- 'org.ofono.NetworkOperator',
136- {
137- 'Name': 'my.cool.telco',
138- 'Status': 'available',
139- 'MobileCountryCode': '777',
140- 'MobileNetworkCode': '22',
141- 'Technologies': ['gsm'],
142- },
143- [
144- ('GetProperties', '', 'a{sv}',
145- 'ret = self.GetAll("org.ofono.NetworkOperator")'),
146- ('Register', '', '', ''),
147- ]
148- )
149+ self.dbusmock.AddObject(
150+ '/ril_0/operator/op2',
151+ 'org.ofono.NetworkOperator',
152+ {
153+ 'Name': 'my.cool.telco',
154+ 'Status': 'available',
155+ 'MobileCountryCode': '777',
156+ 'MobileNetworkCode': '22',
157+ 'Technologies': ['gsm'],
158+ },
159+ [
160+ ('GetProperties', '', 'a{sv}',
161+ 'ret = self.GetAll("org.ofono.NetworkOperator")'),
162+ ('Register', '', '', ''),
163+ ]
164+ )
165 # Add a forbidden carrier
166- self.dbusmock.AddObject('/ril_0/operator/op3',
167- 'org.ofono.NetworkOperator',
168- {
169- 'Name': 'my.bad.telco',
170- 'Status': 'forbidden',
171- 'MobileCountryCode': '777',
172- 'MobileNetworkCode': '22',
173- 'Technologies': ['gsm'],
174- },
175- [
176- ('GetProperties', '', 'a{sv}',
177- 'ret = self.GetAll("org.ofono.NetworkOperator")'),
178- ('Register', '', '', ''),
179- ]
180- )
181+ self.dbusmock.AddObject(
182+ '/ril_0/operator/op3',
183+ 'org.ofono.NetworkOperator',
184+ {
185+ 'Name': 'my.bad.telco',
186+ 'Status': 'forbidden',
187+ 'MobileCountryCode': '777',
188+ 'MobileNetworkCode': '22',
189+ 'Technologies': ['gsm'],
190+ },
191+ [
192+ ('GetProperties', '', 'a{sv}',
193+ 'ret = self.GetAll("org.ofono.NetworkOperator")'),
194+ ('Register', '', '', ''),
195+ ]
196+ )
197 super(UbuntuSystemSettingsOfonoTestCase, self).setUp('cellular')
198
199 @property
200@@ -194,8 +199,7 @@
201 """ Checks whether an space item exists and returns a value """
202 item = self.storage_page.select_single(objectName=object_name)
203 self.assertThat(item, NotEquals(None))
204- label = item.label # Label
205- space = item.value # Disk space (bytes)
206+ label = item.label # Label
207 self.assertThat(label, Equals(text))
208 # Get item's label
209 size_label = item.select_single(objectName='sizeLabel')
210
211=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_about.py'
212--- tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-01-27 16:17:57 +0000
213+++ tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-03-11 15:00:54 +0000
214@@ -8,13 +8,17 @@
215 from time import sleep
216
217 from autopilot.platform import model
218-from autopilot.matchers import Eventually
219 from testtools.matchers import Equals, NotEquals, GreaterThan
220 from unittest import expectedFailure
221
222-from ubuntu_system_settings.tests import AboutBaseTestCase, StorageBaseTestCase, LicenseBaseTestCase
223+from ubuntu_system_settings.tests import (
224+ AboutBaseTestCase,
225+ StorageBaseTestCase,
226+ LicenseBaseTestCase
227+)
228 from ubuntu_system_settings.utils.i18n import ugettext as _
229
230+
231 class AboutTestCase(AboutBaseTestCase):
232 """ Tests for About this phone Page """
233
234@@ -96,7 +100,7 @@
235 """ Tests for Storage """
236
237 def test_storage_page(self):
238- """ Check whether Storage page is available """
239+ """ Check whether Storage page is available """
240 self.assertThat(self.storage_page, NotEquals(None))
241
242 def test_disk(self):
243@@ -136,7 +140,9 @@
244
245 def test_installed_apps(self):
246 """ Checks whether Installed Apps list is available """
247- installed_apps_list_view = self.storage_page.select_single(objectName='installedAppsListView')
248+ installed_apps_list_view = self.storage_page.select_single(
249+ objectName='installedAppsListView'
250+ )
251 self.assertThat(installed_apps_list_view, NotEquals(None))
252
253
254@@ -145,6 +151,5 @@
255
256 @expectedFailure
257 def test_licenses_page(self):
258- """ Check whether Storage page is available """
259+ """ Check whether Storage page is available """
260 self.assertThat(self.licenses_page, NotEquals(None))
261-
262
263=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_cellular.py'
264--- tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2014-02-18 12:16:22 +0000
265+++ tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2014-03-11 15:00:54 +0000
266@@ -5,29 +5,28 @@
267 # under the terms of the GNU General Public License version 3, as published
268 # by the Free Software Foundation.
269
270-from time import sleep
271-
272 from autopilot.introspection.dbus import StateNotFoundError
273-from autopilot.matchers import Eventually
274 from testtools.matchers import Equals, NotEquals, raises
275-from unittest import expectedFailure
276
277 from ubuntu_system_settings.tests import UbuntuSystemSettingsOfonoTestCase
278 from ubuntu_system_settings.utils.i18n import ugettext as _
279
280 from ubuntuuitoolkit import emulators as toolkit_emulators
281
282+
283 class CellularTestCase(UbuntuSystemSettingsOfonoTestCase):
284 """ Tests for cellular Page """
285
286 def navigate_to_manual(self):
287 selector = self.cellular_page.select_single(
288- toolkit_emulators.ItemSelector,
289- objectName="autoChooseCarrierSelector")
290+ toolkit_emulators.ItemSelector,
291+ objectName="autoChooseCarrierSelector"
292+ )
293 manual = selector.select_single('Label', text=_("Manually"))
294 self.pointer.click_object(manual)
295 choosecarrier = self.cellular_page.select_single(
296- objectName="chooseCarrier")
297+ objectName="chooseCarrier"
298+ )
299 self.pointer.click_object(choosecarrier)
300 self.assertThat(self.choose_page.title, Equals(_("Carrier")))
301
302@@ -40,8 +39,9 @@
303 """ Tests whether the current network is visible and selected """
304 self.navigate_to_manual()
305 carriers = self.choose_page.select_single(
306- toolkit_emulators.ItemSelector,
307- objectName="carrierSelector")
308+ toolkit_emulators.ItemSelector,
309+ objectName="carrierSelector"
310+ )
311 # TODO: Once there is a proper ItemSelector emulator, get the items
312 # from it and check 'fake.tel' is the selected one.
313 manual = carriers.select_single('Label', text="fake.tel")
314@@ -52,8 +52,9 @@
315 """ Tests whether an alternative available network is displayed """
316 self.navigate_to_manual()
317 carriers = self.choose_page.select_single(
318- toolkit_emulators.ItemSelector,
319- objectName="carrierSelector")
320+ toolkit_emulators.ItemSelector,
321+ objectName="carrierSelector"
322+ )
323 manual = carriers.select_single('Label', text="my.cool.telco")
324 self.assertThat(manual, NotEquals(None))
325
326@@ -61,7 +62,10 @@
327 """ Ensures that a forbidden network is not shown """
328 self.navigate_to_manual()
329 carriers = self.choose_page.select_single(
330- toolkit_emulators.ItemSelector,
331- objectName="carrierSelector")
332- self.assertThat(lambda: carriers.select_single('Label', text="my.bad.telco"),
333- raises(StateNotFoundError))
334+ toolkit_emulators.ItemSelector,
335+ objectName="carrierSelector"
336+ )
337+ self.assertThat(
338+ lambda: carriers.select_single('Label', text="my.bad.telco"),
339+ raises(StateNotFoundError)
340+ )
341
342=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_datetime.py'
343--- tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2014-01-30 16:42:51 +0000
344+++ tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2014-03-11 15:00:54 +0000
345@@ -5,12 +5,10 @@
346 # under the terms of the GNU General Public License version 3, as published
347 # by the Free Software Foundation.
348
349-import dbus
350 import dbusmock
351 import subprocess
352 from time import sleep
353
354-from autopilot.platform import model
355 from autopilot.matchers import Eventually
356 from testtools.matchers import Equals, NotEquals, GreaterThan
357
358@@ -19,6 +17,7 @@
359
360 from ubuntuuitoolkit import emulators as toolkit_emulators
361
362+
363 class TimeDateTestCase(UbuntuSystemSettingsTestCase,
364 dbusmock.DBusTestCase):
365 """ Tests for the Time & Date Page """
366@@ -27,8 +26,9 @@
367 def setUpClass(klass):
368 klass.start_system_bus()
369 klass.dbus_con = klass.get_dbus(True)
370- (klass.p_mock,klass.obj_timedate1) = klass.spawn_server_template(
371- 'timedated', {}, stdout=subprocess.PIPE)
372+ (klass.p_mock, klass.obj_timedate1) = klass.spawn_server_template(
373+ 'timedated', {}, stdout=subprocess.PIPE
374+ )
375
376 def setUp(self):
377 """ Go to Time & Date page """
378@@ -45,7 +45,9 @@
379
380 def click_tz_search_field(self):
381 self.scroll_to_and_click(self.tz_page)
382- text_field = self.main_view.select_single(objectName='selectTimeZoneField')
383+ text_field = self.main_view.select_single(
384+ objectName='selectTimeZoneField'
385+ )
386 self.pointer.move_to_object(text_field)
387
388 def test_time_date_page(self):
389@@ -56,14 +58,17 @@
390 def test_tz_list_initially_empty(self):
391 """ Checks that no list is displayed initially """
392 self.scroll_to_and_click(self.tz_page)
393- labelVisible = self.main_view.select_single(objectName='nothingLabel').visible
394+ labelVisible = self.main_view.select_single(
395+ objectName='nothingLabel').visible
396 self.assertThat(labelVisible, Equals(True))
397
398 def test_searching_tz(self):
399 """ Check that searching for a valid location shows something """
400 self.click_tz_search_field()
401 self.keyboard.type('London, United Kingdom')
402- listview = self.main_view.select_single(objectName='locationsListView')
403+ listview = self.main_view.select_single(
404+ objectName='locationsListView'
405+ )
406 self.assertThat(listview.count, GreaterThan(0))
407
408 def test_searching_tz_not_found(self):
409@@ -72,7 +77,8 @@
410 self.keyboard.type('Oh no you don\'t!')
411 listview = self.main_view.select_single(objectName='locationsListView')
412 self.assertThat(listview.count, Equals(0))
413- labelVisible = self.main_view.select_single(objectName='nothingLabel').visible
414+ labelVisible = self.main_view.select_single(
415+ objectName='nothingLabel').visible
416 self.assertThat(labelVisible, Equals(True))
417
418 def test_manual_tz_selection(self):
419@@ -87,8 +93,9 @@
420 self.assertThat(self.tz_page.text, Equals('Europe/London'))
421
422 def test_same_tz_selection(self):
423- """ Check that manually setting a timezone then setting the same one doesn't
424- take you back to the index """
425+ """Check that manually setting a timezone then setting the same one
426+ doesn't take you back to the index.
427+ """
428 self.test_manual_tz_selection()
429 self.click_tz_search_field()
430 # This is also in Europe/London
431
432=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_plugins.py'
433--- tests/autopilot/ubuntu_system_settings/tests/test_plugins.py 2014-01-21 17:23:50 +0000
434+++ tests/autopilot/ubuntu_system_settings/tests/test_plugins.py 2014-03-11 15:00:54 +0000
435@@ -5,17 +5,18 @@
436 # under the terms of the GNU General Public License version 3, as published
437 # by the Free Software Foundation.
438
439-from time import sleep
440-
441 from autopilot.introspection.dbus import StateNotFoundError
442 from autopilot.matchers import Eventually
443-from testtools.matchers import Contains, Equals, NotEquals, GreaterThan, raises
444+from testtools.matchers import Equals, NotEquals, raises
445
446-from ubuntu_system_settings.tests import (UbuntuSystemSettingsTestCase,
447- UbuntuSystemSettingsUpowerTestCase,
448- UbuntuSystemSettingsBatteryTestCase)
449+from ubuntu_system_settings.tests import (
450+ UbuntuSystemSettingsTestCase,
451+ UbuntuSystemSettingsUpowerTestCase,
452+ UbuntuSystemSettingsBatteryTestCase
453+)
454 from ubuntu_system_settings.utils.i18n import ugettext as _
455
456+
457 class SystemSettingsTestCases(UbuntuSystemSettingsTestCase):
458 """ Tests for Ubuntu System Settings """
459
460@@ -27,30 +28,40 @@
461 header = self.main_view.select_single(objectName='systemSettingsPage')
462 self.assertThat(header, NotEquals(None))
463 self.assertThat(header.title, Eventually(Equals(_('System Settings'))))
464-
465+
466 def test_search(self):
467 """ Checks whether the Search box is available """
468 search = self.main_view.select_single(objectName='searchTextField')
469 self.assertThat(search, NotEquals(None))
470-
471+
472 def test_network_category(self):
473 """ Checks whether the Network category is available """
474- category = self.main_view.select_single(objectName='categoryGrid-network')
475+ category = self.main_view.select_single(
476+ objectName='categoryGrid-network'
477+ )
478 self.assertThat(category, NotEquals(None))
479- self.assertThat(category.categoryName, Eventually(Equals(_('Network'))))
480-
481+ self.assertThat(
482+ category.categoryName, Eventually(Equals(_('Network')))
483+ )
484+
485 def test_personal_category(self):
486 """ Checks whether the Personal category is available """
487- category = self.main_view.select_single(objectName='categoryGrid-personal')
488+ category = self.main_view.select_single(
489+ objectName='categoryGrid-personal'
490+ )
491 self.assertThat(category, NotEquals(None))
492- self.assertThat(category.categoryName, Eventually(Equals(_('Personal'))))
493-
494+ self.assertThat(
495+ category.categoryName, Eventually(Equals(_('Personal')))
496+ )
497+
498 def test_system_category(self):
499 """ Checks whether the System category is available """
500- category = self.main_view.select_single(objectName='categoryGrid-system')
501+ category = self.main_view.select_single(
502+ objectName='categoryGrid-system'
503+ )
504 self.assertThat(category, NotEquals(None))
505 self.assertThat(category.categoryName, Eventually(Equals(_('System'))))
506-
507+
508 def test_wifi_plugin(self):
509 """ Checks whether the Wi-Fi plugin is available """
510 plugin = self.main_view.select_single(objectName='entryComponent-wifi')
511@@ -58,70 +69,97 @@
512
513 def test_cellular_plugin(self):
514 """ Checks whether the Cellunar plugin is available """
515- plugin = self.main_view.select_single(objectName='entryComponent-cellular')
516+ plugin = self.main_view.select_single(
517+ objectName='entryComponent-cellular'
518+ )
519 self.assertThat(plugin, NotEquals(None))
520
521 def test_bluetooth_plugin(self):
522 """ Checks whether the Bluetooth plugin is available """
523- plugin = self.main_view.select_single(objectName='entryComponent-bluetooth')
524+ plugin = self.main_view.select_single(
525+ objectName='entryComponent-bluetooth'
526+ )
527 self.assertThat(plugin, NotEquals(None))
528
529 def test_background_plugin(self):
530 """ Checks whether the Background plugin is available """
531- plugin = self.main_view.select_single(objectName='entryComponent-background')
532+ plugin = self.main_view.select_single(
533+ objectName='entryComponent-background'
534+ )
535 self.assertThat(plugin, NotEquals(None))
536
537 def test_sound_plugin(self):
538 """ Checks whether the Sound plugin is available """
539- plugin = self.main_view.select_single(objectName='entryComponent-sound')
540+ plugin = self.main_view.select_single(
541+ objectName='entryComponent-sound'
542+ )
543 self.assertThat(plugin, NotEquals(None))
544
545 def test_language_plugin(self):
546 """ Checks whether the Language plugin is available """
547- plugin = self.main_view.select_single(objectName='entryComponent-language')
548+ plugin = self.main_view.select_single(
549+ objectName='entryComponent-language'
550+ )
551 self.assertThat(plugin, NotEquals(None))
552
553 def test_accounts_plugin(self):
554 """ Checks whether the Accounts plugin is available """
555- plugin = self.main_view.select_single(objectName='entryComponent-online-accounts')
556+ plugin = self.main_view.select_single(
557+ objectName='entryComponent-online-accounts'
558+ )
559 self.assertThat(plugin, NotEquals(None))
560
561 def test_timedate_plugin(self):
562 """ Checks whether the Time & Date plugin is available """
563- plugin = self.main_view.select_single(objectName='entryComponent-time-date')
564+ plugin = self.main_view.select_single(
565+ objectName='entryComponent-time-date'
566+ )
567 self.assertThat(plugin, NotEquals(None))
568
569 def test_security_plugin(self):
570 """ Checks whether the Security plugin is available """
571- plugin = self.main_view.select_single(objectName='entryComponent-security-privacy')
572+ plugin = self.main_view.select_single(
573+ objectName='entryComponent-security-privacy'
574+ )
575 self.assertThat(plugin, NotEquals(None))
576
577 def test_updates_plugin(self):
578 """ Checks whether the Updates plugin is available """
579- plugin = self.main_view.select_single(objectName='entryComponent-system-update')
580+ plugin = self.main_view.select_single(
581+ objectName='entryComponent-system-update'
582+ )
583 self.assertThat(plugin, NotEquals(None))
584
585+
586 class SystemSettingsUpowerTestCases(UbuntuSystemSettingsUpowerTestCase):
587 def setUp(self):
588 super(SystemSettingsUpowerTestCases, self).setUp()
589
590 def test_no_battery_plugin_without_battery(self):
591- """ Checks whether the Battery plugin is not available as we have no battery """
592- self.assertThat(lambda: self.main_view.select_single(objectName='entryComponent-battery'),
593- raises(StateNotFoundError))
594+ """ Checks whether the Battery plugin is not available as we
595+ have no battery.
596+ """
597+ self.assertThat(lambda: self.main_view.select_single(
598+ objectName='entryComponent-battery'),
599+ raises(StateNotFoundError)
600+ )
601
602 def test_battery_plugin_battery_hotplugging(self):
603 """ Checks whether hotplugging a battery makes the panel visible """
604 self.add_mock_battery()
605- plugin = self.main_view.select_single(objectName='entryComponent-battery')
606+ plugin = self.main_view.select_single(
607+ objectName='entryComponent-battery'
608+ )
609 self.assertThat(plugin, NotEquals(None))
610
611+
612 class SystemSettingsBatteryTestCases(UbuntuSystemSettingsBatteryTestCase):
613 def setUp(self):
614 super(SystemSettingsBatteryTestCases, self).setUp()
615
616 def test_battery_plugin(self):
617 """ checks whether the Battery plugin is available """
618- plugin = self.main_view.select_single(objectName='entryComponent-battery')
619+ plugin = self.main_view.select_single(
620+ objectName='entryComponent-battery'
621+ )
622 self.assertThat(plugin, NotEquals(None))
623-
624
625=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_search.py'
626--- tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-01-17 10:15:31 +0000
627+++ tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-03-11 15:00:54 +0000
628@@ -5,12 +5,8 @@
629 # under the terms of the GNU General Public License version 3, as published
630 # by the Free Software Foundation.
631
632-from time import sleep
633-
634-from autopilot.matchers import Eventually
635 from autopilot.introspection.dbus import StateNotFoundError
636-from testtools.matchers import Contains, Equals, NotEquals, GreaterThan
637-from unittest import skip
638+from testtools.matchers import Equals, NotEquals
639
640 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
641 from ubuntu_system_settings.utils.i18n import ugettext as _
642@@ -18,6 +14,7 @@
643
644 """ Tests for Ubuntu System Settings """
645
646+
647 class SearchTestCases(UbuntuSystemSettingsTestCase):
648 """ Tests for Search """
649
650@@ -37,8 +34,9 @@
651 sound = self.main_view.select_single(objectName='entryComponent-sound')
652 self.assertThat(sound, NotEquals(None))
653 try:
654- background = self.main_view.select_single(objectName='entryComponent-background')
655+ background = self.main_view.select_single(
656+ objectName='entryComponent-background'
657+ )
658 except StateNotFoundError:
659 background = None
660 self.assertThat(background, Equals(None))
661-
662
663=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_system_updates.py'
664--- tests/autopilot/ubuntu_system_settings/tests/test_system_updates.py 2014-02-04 21:05:28 +0000
665+++ tests/autopilot/ubuntu_system_settings/tests/test_system_updates.py 2014-03-11 15:00:54 +0000
666@@ -5,15 +5,10 @@
667 # under the terms of the GNU General Public License version 3, as published
668 # by the Free Software Foundation.
669
670-from time import sleep
671-
672-from autopilot.matchers import Eventually
673 from autopilot.introspection.dbus import StateNotFoundError
674-from testtools.matchers import Contains, Equals, NotEquals, GreaterThan, raises
675-from unittest import skip
676+from testtools.matchers import NotEquals, raises
677
678 from ubuntu_system_settings.tests import SystemUpdatesBaseTestCase
679-from ubuntu_system_settings.utils.i18n import ugettext as _
680
681
682 """ Tests for Ubuntu System Settings """
683
684=== modified file 'tests/autopilot/ubuntu_system_settings/utils/i18n.py'
685--- tests/autopilot/ubuntu_system_settings/utils/i18n.py 2013-12-17 17:29:03 +0000
686+++ tests/autopilot/ubuntu_system_settings/utils/i18n.py 2014-03-11 15:00:54 +0000
687@@ -8,15 +8,17 @@
688 import locale
689 import gettext
690
691-APP_NAME='ubuntu-system-settings'
692-LOCALE_DIR='/usr/share/locale/'
693+APP_NAME = 'ubuntu-system-settings'
694+LOCALE_DIR = '/usr/share/locale/'
695
696 lc, encoding = locale.getdefaultlocale()
697
698 if not lc:
699 lc = 'C'
700
701-language = gettext.translation(APP_NAME, LOCALE_DIR, languages=[lc], fallback=True)
702+language = gettext.translation(
703+ APP_NAME, LOCALE_DIR, languages=[lc], fallback=True
704+)
705
706 # UTF-8
707 ugettext = language.ugettext
708
709=== added file 'tests/test_code.py'
710--- tests/test_code.py 1970-01-01 00:00:00 +0000
711+++ tests/test_code.py 2014-03-11 15:00:54 +0000
712@@ -0,0 +1,47 @@
713+#!/usr/bin/python
714+
715+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
716+# Copyright 2014 Canonical
717+#
718+# This program is free software: you can redistribute it and/or modify it
719+# under the terms of the GNU General Public License version 3, as published
720+# by the Free Software Foundation.
721+
722+import subprocess
723+import sys
724+import unittest
725+
726+
727+class StaticCodeTests(unittest.TestCase):
728+
729+ def _is_tool_installed(tool):
730+ return subprocess.call(['which', tool],
731+ stdout=subprocess.PIPE)
732+
733+ @unittest.skipIf(
734+ _is_tool_installed('pyflakes') != 0, 'pyflakes not installed'
735+ )
736+ def test_pyflakes(self):
737+ pyflakes = subprocess.Popen(
738+ ['pyflakes', '.'],
739+ stdout=subprocess.PIPE, universal_newlines=True
740+ )
741+ (out, err) = pyflakes.communicate()
742+ self.assertEqual(pyflakes.returncode, 0, out)
743+
744+ @unittest.skipIf(
745+ _is_tool_installed('pep8') != 0, 'pep8 not installed'
746+ )
747+ def test_pep8(self):
748+ pep8 = subprocess.Popen(
749+ ['pep8', '.'],
750+ stdout=subprocess.PIPE, universal_newlines=True
751+ )
752+ (out, err) = pep8.communicate()
753+ self.assertEqual(pep8.returncode, 0, out)
754+
755+
756+if __name__ == '__main__':
757+ unittest.main(
758+ testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
759+ )

Subscribers

People subscribed via source and target branches