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

Proposed by Omer Akram
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 665
Merged at revision: 681
Proposed branch: lp:~om26er/ubuntu-system-settings/fix_tests
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~vrruiz/ubuntu-system-settings/helper-launch-system-settings
Diff against target: 475 lines (+221/-119)
5 files modified
plugins/about/License.qml (+0/-1)
plugins/about/Software.qml (+1/-0)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+20/-8)
tests/autopilot/ubuntu_system_settings/tests/test_about.py (+177/-91)
tests/autopilot/ubuntu_system_settings/tests/test_search.py (+23/-19)
To merge this branch: bzr merge lp:~om26er/ubuntu-system-settings/fix_tests
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+213691@code.launchpad.net

This proposal supersedes a proposal from 2014-03-09.

Commit message

autopilot tests improvements:
 * Improved existing tests to compare values with backends instead of just testing the 'item' is there.
 * Fixed a skipped failing test
 * Delete label tests and those which are trying to make sure certain elements exist.

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: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

\o/

On Tue, Mar 11, 2014 at 4:17 AM, PS Jenkins bot <
<email address hidden>> wrote:

> Review: Approve continuous-integration
>
> PASSED: Continuous integration, rev:649
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/693/
> Executed test runs:
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3801
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3386
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-amd64-ci/209
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-armhf-ci/197
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-i386-ci/196
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3338
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3819
> deb:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3819/artifact/work/output/*zip*/output.zip
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3388
> deb:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3388/artifact/work/output/*zip*/output.zip
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5754
> SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4639
>
> Click here to trigger a rebuild:
> http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/693/rebuild
>
> --
>
> https://code.launchpad.net/~om26er/ubuntu-system-settings/fix_tests/+merge/210102
> You are the owner of lp:~om26er/ubuntu-system-settings/fix_tests.
>

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: 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
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Thank you for your work, that looks mostly fine, 3 of the StorageTestCase tests fail if the xdg directories are missing though

e.g

"Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ubuntu_system_settings/tests/test_about.py", line 161, in test_space_used_by_music
    music_space = self._get_space_by_directory('Music')
  File "/usr/lib/python2.7/dist-packages/ubuntu_system_settings/tests/test_about.py", line 131, in _get_space_by_directory
    output = subprocess.check_output(['du', '--block-size=1', location])
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['du', '--block-size=1', '/home/user/Videos']' returned non-zero exit status 1

same for Pictures and Music

Those directories are translated if you use a different locale (e.g they are "Vidéos" "Images" "Musique" on a french system). You either need to restore the translations or handle the directories not being there

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

Thanks for the review, I have fixed that problem, now we are translating those names.

Revision history for this message
Iain Lane (laney) wrote : Posted in a previous version of this proposal

Drive-by commenting...

On Tue, Apr 01, 2014 at 04:22:31PM -0000, Omer Akram wrote:
> Thanks for the review, I have fixed that problem, now we are translating those names.

You can do this more flexibly (since users are allowed to change these
directories to anything they want) by retrieving the actual user dir in
use.

For example using GLib with gi like so:

>>> from gi.repository import GLib
>>> GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
'/home/laney/Music'

It's not essential, but it'd be nice to do that this time round if you
can. This is the kind of enhancement that falls through the cracks.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

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, the tests still can fail though (if you run under a C local on a non english desktop, or if the directories are missing), the proper solution is the one hinted by Laney. We should also handle without failing the case when one of the directory is missing on disk (which can happen)

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

FAILED: Continuous integration, rev:654
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/fix_tests/+merge/213691/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/752/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4433
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4031
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-amd64-ci/268
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-armhf-ci/256
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-i386-ci/255
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3833
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4537
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4537/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4055
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4055/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6289
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5502

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

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

> 222 + @skipUnless(
> 223 + model() == 'Nexus 4',
> 224 + 'Nexus 4 is currently the only telephony device that we support'
> 225 + )
> 226 + def test_imei_information_is_correct(self):

Is there a way we could make that more dynamic and check through ofono for the imei information being there, instead of coding a specific model in the test?

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

same about the model() == 'Desktop' skips, can't we just check for the service/command to be there or not and handle the case where it's not?

Revision history for this message
Iain Lane (laney) wrote :

> Is there a way we could make that more dynamic and check through ofono for the
> imei information being there, instead of coding a specific model in the test?

It should display 'N/A' when no IMEI is available.

I see some tests that are skipped on desktop too - do you think we could test the corresponding desktop case as well?

Revision history for this message
Iain Lane (laney) wrote :

> I see some tests that are skipped on desktop too - do you think we could test
> the corresponding desktop case as well?

Like check if the data is available and if it's not that the correct 'not available' string is displayed in the UI, instead of having conditional skips.

655. By Omer Akram

use glib to get directory locations inside HOME

656. By Omer Akram

make tests more solid by using Eventually

657. By Omer Akram

skip test if the directory does not exist

658. By Omer Akram

don't skip tests based on platform, rather handle cases in code

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
659. By Omer Akram

skip test if getprop is not found instead of making it platform dependent

660. By Omer Akram

fix pep8/pyflakes complaints

Revision history for this message
Omer Akram (om26er) wrote :

Thanks for the review. I have fixed everything suggested above.

Now getting directory locations from GLib and if a directory does not exist we skip the test gracefully.
Also not skipping tests based on what platforms they are run on rather checking if the required functionality is available to use, also enhances the tests a bit to tests the cases for Desktop scenario.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
661. By Omer Akram

merge with trunk, fix conflicts

Revision history for this message
Omer Akram (om26er) wrote :

Merged with trunk again and fixed conflicts.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
662. By Omer Akram

fix

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

thanks

> 217 +
> 218 + if model() == 'Desktop':
> 219 + self.assertThat(item.visible, Equals(False))

that still special case "Desktop", which means those would fail on e.g a tablet, can't you just call self._get_device_serial_number() and test if the return is empty/null?

Looks fine out of those issues (same for serial and imei)

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

oh, another issues, the checks for the space used by the movie/music/picture directories fail if the computation takes more than 10 seconds (they value are only displayed when all results are received, or the "space taken by Ubuntu" can easily take a minute on a desktop installation)

Not sure how to address those though, does anyone has a suggestion?

663. By Omer Akram

don't skip tests based on platform, rather check if the required backend is availabe or not and test accordingly

664. By Omer Akram

skip disk storage tests on desktop as they can fail because the calculation can take a long time, bug 1304328

Revision history for this message
Omer Akram (om26er) wrote :

> thanks
>
> > 217 +
> > 218 + if model() == 'Desktop':
> > 219 + self.assertThat(item.visible, Equals(False))
>
> that still special case "Desktop", which means those would fail on e.g a
> tablet, can't you just call self._get_device_serial_number() and test if the
> return is empty/null?
>
> Looks fine out of those issues (same for serial and imei)

Fixed that now.

Revision history for this message
Omer Akram (om26er) wrote :

> oh, another issues, the checks for the space used by the movie/music/picture
> directories fail if the computation takes more than 10 seconds (they value are
> only displayed when all results are received, or the "space taken by Ubuntu"
> can easily take a minute on a desktop installation)
>
> Not sure how to address those though, does anyone has a suggestion?

As discussed on IRC, I have skipped those tests on the Desktop and reported bug 1304328 to track what needs to be changed in the system settings.

Revision history for this message
Sebastien Bacher (seb128) wrote :

> As discussed on IRC, I have skipped those tests on the Desktop

We didn't say "on the Desktop", as in previous comment I don't think we should special case Desktop. The factor there is how much datas you have and how slow the storage access is. Looking at an android tablet it's likely that the estimate are going to take longer than 10 seconds on devices as well... can we just skip those tests, and not only on desktop, as long as they are not reliable

review: Needs Fixing
665. By Omer Akram

skip disk space tests, in some cases they can be slow

Revision history for this message
Omer Akram (om26er) wrote :

> > As discussed on IRC, I have skipped those tests on the Desktop
>
> We didn't say "on the Desktop", as in previous comment I don't think we should
> special case Desktop. The factor there is how much datas you have and how slow
> the storage access is. Looking at an android tablet it's likely that the
> estimate are going to take longer than 10 seconds on devices as well... can we
> just skip those tests, and not only on desktop, as long as they are not
> reliable

Now they are skipped.

Given the amount of disk space on touch devices (max 64GB currently) and only a limited part of them allocated for the system partition i.e. where Ubuntu is installed, I believe this would not have caused trouble for us, at least if we gave the calculations a few retries just to be sure. Though I do agree that on the desktop we never be sure.

Revision history for this message
Sebastien Bacher (seb128) wrote :

> Now they are skipped.

thanks!

> i.e. where Ubuntu is installed, I believe this would not have caused trouble for us, at least if we gave the calculations a few retries just to be sure

well
- even on small disk it's easy to go over 10 seconds (I've seen android devices taking over 30 seconds on devices with 16GB of disk)
- having to retry sometime is a no go, we don't want flacky tests
- we need to design the tests to be robust on any device, not just to work on a new install in the QA test config

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)
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
=== modified file 'plugins/about/License.qml'
--- plugins/about/License.qml 2014-03-04 12:45:06 +0000
+++ plugins/about/License.qml 2014-04-08 12:01:45 +0000
@@ -8,7 +8,6 @@
8 property string binary;8 property string binary;
99
10 id: licensesPage10 id: licensesPage
11 objectName: "licensesPage"
12 title: binary11 title: binary
13 flickable: scrollWidget12 flickable: scrollWidget
1413
1514
=== modified file 'plugins/about/Software.qml'
--- plugins/about/Software.qml 2013-07-29 14:08:10 +0000
+++ plugins/about/Software.qml 2014-04-08 12:01:45 +0000
@@ -7,6 +7,7 @@
77
8ItemPage {8ItemPage {
9 id: licensesPage9 id: licensesPage
10 objectName: "licensesPage"
10 title: i18n.tr("Software licenses")11 title: i18n.tr("Software licenses")
11 flickable: softwareList12 flickable: softwareList
1213
1314
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-03-31 15:42:50 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-04-08 12:01:45 +0000
@@ -9,7 +9,6 @@
99
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from ubuntu_system_settings.utils.i18n import ugettext as _
13from ubuntu_system_settings import helpers12from ubuntu_system_settings import helpers
1413
15from autopilot.input import Mouse, Touch, Pointer14from autopilot.input import Mouse, Touch, Pointer
@@ -163,6 +162,7 @@
163 def setUp(self):162 def setUp(self):
164 """ Go to About page """163 """ Go to About page """
165 super(AboutBaseTestCase, self).setUp('about')164 super(AboutBaseTestCase, self).setUp('about')
165 self.assertThat(self.about_page.active, Eventually(Equals(True)))
166166
167 @property167 @property
168 def about_page(self):168 def about_page(self):
@@ -177,10 +177,13 @@
177 """ Go to Storage Page """177 """ Go to Storage Page """
178 super(StorageBaseTestCase, self).setUp()178 super(StorageBaseTestCase, self).setUp()
179 # Click on 'Storage' option179 # Click on 'Storage' option
180 button = self.about_page.select_single(objectName='storageItem')180 button = self.about_page.select_single(
181 self.assertThat(button, NotEquals(None))181 'Standard', objectName='storageItem'
182 )
182 self.scroll_to_and_click(button)183 self.scroll_to_and_click(button)
183184
185 self.assertThat(self.storage_page.active, Eventually(Equals(True)))
186
184 def assert_space_item(self, object_name, text):187 def assert_space_item(self, object_name, text):
185 """ Checks whether an space item exists and returns a value """188 """ Checks whether an space item exists and returns a value """
186 item = self.storage_page.select_single(objectName=object_name)189 item = self.storage_page.select_single(objectName=object_name)
@@ -193,10 +196,17 @@
193 values = size_label.text.split(' ') # Format: "00.0 (bytes|MB|GB)"196 values = size_label.text.split(' ') # Format: "00.0 (bytes|MB|GB)"
194 self.assertThat(len(values), GreaterThan(1))197 self.assertThat(len(values), GreaterThan(1))
195198
199 def get_storage_space_used_by_category(self, objectName):
200 return self.main_view.wait_select_single(
201 'StorageItem', objectName=objectName
202 ).value
203
196 @property204 @property
197 def storage_page(self):205 def storage_page(self):
198 """ Return 'Storage' page """206 """ Return 'Storage' page """
199 return self.main_view.select_single(objectName='storagePage')207 return self.main_view.select_single(
208 'Storage', objectName='storagePage'
209 )
200210
201211
202class LicenseBaseTestCase(AboutBaseTestCase):212class LicenseBaseTestCase(AboutBaseTestCase):
@@ -206,15 +216,17 @@
206 """ Go to License Page """216 """ Go to License Page """
207 super(LicenseBaseTestCase, self).setUp()217 super(LicenseBaseTestCase, self).setUp()
208 # Click on 'Software licenses' option218 # Click on 'Software licenses' option
209 button = self.main_view.select_single(objectName='licenseItem')219 button = self.main_view.select_single(
210 self.assertThat(button, NotEquals(None))220 'Standard', objectName='licenseItem'
211 self.assertThat(button.text, Equals(_('Software licenses')))221 )
212 self.scroll_to_and_click(button)222 self.scroll_to_and_click(button)
213223
214 @property224 @property
215 def licenses_page(self):225 def licenses_page(self):
216 """ Return 'License' page """226 """ Return 'License' page """
217 return self.main_view.select_single(objectName='licensesPage')227 return self.main_view.wait_select_single(
228 'ItemPage', objectName='licensesPage'
229 )
218230
219231
220class SystemUpdatesBaseTestCase(UbuntuSystemSettingsTestCase):232class SystemUpdatesBaseTestCase(UbuntuSystemSettingsTestCase):
221233
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_about.py'
--- tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-04-02 09:06:34 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-04-08 12:01:45 +0000
@@ -5,11 +5,15 @@
5# under the terms of the GNU General Public License version 3, as published5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8from time import sleep8import os
99import subprocess
10from autopilot.platform import model10import unittest
11from testtools.matchers import Equals, NotEquals, GreaterThan11
12from unittest import expectedFailure12from gi.repository import GLib
13
14from autopilot.matchers import Eventually
15from testtools import skipIf
16from testtools.matchers import Equals, NotEquals
1317
14from ubuntu_system_settings.tests import (18from ubuntu_system_settings.tests import (
15 AboutBaseTestCase,19 AboutBaseTestCase,
@@ -18,97 +22,148 @@
18)22)
19from ubuntu_system_settings.utils.i18n import ugettext as _23from ubuntu_system_settings.utils.i18n import ugettext as _
2024
25import dbus
26
2127
22class AboutTestCase(AboutBaseTestCase):28class AboutTestCase(AboutBaseTestCase):
23 """ Tests for About this phone Page """29 """ Tests for About this phone Page """
2430
25 def test_about_page(self):31 def _get_imei_from_dbus(self):
26 """ Checks whether About page is available """32 bus = dbus.SystemBus()
27 self.assertThat(self.about_page, NotEquals(None))33 try:
28 self.assertThat(self.about_page.title, Equals(_('About this phone')))34 manager = dbus.Interface(
2935 bus.get_object('org.ofono', '/'), 'org.ofono.Manager'
30 def test_device(self):36 )
31 """ Checks whether Device info is shown """37 except dbus.exceptions.DBusException:
32 device_label = self.about_page.select_single(objectName='deviceLabel')38 # oFono interface not found, probably its a desktop.
33 self.assertThat(device_label, NotEquals(None))39 return None
34 self.assertThat(device_label.text, NotEquals(''))40
41 modems = manager.GetModems()
42 for path, properties in modems:
43 return properties['Serial']
44
45 def _get_os_name(self):
46 os_id = subprocess.check_output(['lsb_release', '-is'])
47 os_release = subprocess.check_output(['lsb_release', '-rs'])
48
49 return '{} {}'.format(os_id.strip(), os_release.strip())
50
51 def _get_device_serial_number(self):
52 try:
53 return subprocess.check_output(['getprop', 'ro.serialno']).strip()
54 except OSError:
55 # getprop is only available on android hardware.
56 return None
57
58 def _get_device_manufacturer_and_model(self):
59 manufacturer = subprocess.check_output(
60 ['getprop', 'ro.product.manufacturer']
61 ).strip()
62 hw_model = subprocess.check_output(
63 ['getprop', 'ro.product.model']
64 ).strip()
65
66 return '{} {}'.format(manufacturer, hw_model)
67
68 def _get_system_image_iface(self):
69 bus = dbus.SystemBus()
70 service = bus.get_object('com.canonical.SystemImage', '/Service')
71 iface = dbus.Interface(service, 'com.canonical.SystemImage')
72 return iface.Info()
73
74 def _get_last_updated_date(self):
75 info = self._get_system_image_iface()[3]
76
77 if info == 'Unknown':
78 return _('Never')
79 else:
80 return str(info.split()[0])
3581
36 def test_serial(self):82 def test_serial(self):
37 """ Checks whether Serial info is available """83 """Checks whether the UI is showing the correct serial number."""
38 item = self.about_page.select_single(objectName='serialItem')84 item = self.about_page.select_single(objectName='serialItem')
39 if (model() == 'Desktop'):85 serial = self._get_device_serial_number()
40 self.assertThat(item.visible, Equals(False))86
41 else:87 if not serial:
42 self.assertThat(item.visible, Equals(True))88 self.assertThat(item.visible, Equals(False))
43 self.assertThat(item.text, Equals(_('Serial')))89 else:
44 self.assertThat(item.value, NotEquals(_('N/A')))90 self.assertThat(
4591 item.value, Equals(self._get_device_serial_number())
46 def test_imei(self):92 )
47 """ Checks whether IMEI info is available """93
48 item = self.about_page.select_single(objectName='imeiItem')94 def test_imei_information_is_correct(self):
49 if (model() == 'Desktop'):95 """Checks whether the UI is exposing the right IMEI."""
50 self.assertThat(item.visible, Equals(False))96 imei_item = self.about_page.wait_select_single(
51 else:97 objectName='imeiItem')
52 self.assertThat(item.visible, Equals(True))98 imei_ofono = self._get_imei_from_dbus()
53 self.assertThat(item.text, Equals(_('IMEI')))99
54 self.assertThat(item.value, NotEquals(_('N/A')))100 if not imei_ofono:
55101 self.assertThat(imei_item.visible, Equals(False))
56 def test_software(self):102 else:
57 """ Checks whether Software info is available """103 self.assertEquals(imei_item.value, imei_ofono)
58 item = self.about_page.select_single(objectName='softwareItem')104
59 self.assertThat(item, NotEquals(None))105 def test_settings_show_correct_version_of_the_os(self):
60 self.assertThat(item.text, Equals(_('Software:')))106 """Ensure the UI is showing the correct version of the OS."""
61
62 def test_os(self):
63 """ Checks whether OS info is available """
64 item = self.about_page.select_single(objectName='osItem')107 item = self.about_page.select_single(objectName='osItem')
65 self.assertThat(item, NotEquals(None))108 # TODO: find a way to check the image build number as well
66 self.assertThat(item.text, Equals(_('OS')))109 # -- om26er 10-03-2014
67 info = item.value.split()110 self.assertTrue(self._get_os_name() in item.value)
68 self.assertThat(len(info), GreaterThan(1))111
69 self.assertThat(info[0], Equals(_('Ubuntu')))112 @skipIf(subprocess.call(
70 self.assertThat(info[1], NotEquals(''))113 ['which', 'getprop'], stdout=subprocess.PIPE) != 0,
71 if (len(info) > 2):114 'program "getprop" not found'
72 self.assertThat(info[2], NotEquals(''))115 )
116 def test_hardware_name(self):
117 """Ensure the UI is showing the correct device name."""
118 device_label = self.about_page.select_single(
119 objectName='deviceLabel'
120 ).text
121 device_name_from_getprop = self._get_device_manufacturer_and_model()
122
123 self.assertEquals(device_label, device_name_from_getprop)
73124
74 def test_last_updated(self):125 def test_last_updated(self):
75 """ Checks whether Last Updated info is available """126 """Checks whether Last Updated info is correct."""
76 item = self.about_page.select_single(objectName='lastUpdatedItem')127 last_updated = self.about_page.select_single(
77 self.assertThat(item, NotEquals(None))128 objectName='lastUpdatedItem'
78 self.assertThat(item.text, Equals(_('Last updated')))129 ).value
79 date = item.value.split('-')130
80 if (len(date) == 1):131 self.assertEquals(last_updated, self._get_last_updated_date())
81 self.assertThat(item.value, Equals(_('Never')))
82 else:
83 # 2013-10-19
84 self.assertThat(len(item.value), Equals(10))
85
86 def test_legal(self):
87 """ Checks whether Legal info is available """
88 item = self.about_page.select_single(objectName='legalItem')
89 self.assertThat(item, NotEquals(None))
90 self.assertThat(item.text, Equals(_('Legal:')))
91
92 def test_update(self):
93 """ Checks whether Update button is available """
94 button = self.about_page.select_single(objectName='updateButton')
95 self.assertThat(button, NotEquals(None))
96 self.assertThat(button.text, Equals(_('Check for updates')))
97132
98133
99class StorageTestCase(StorageBaseTestCase):134class StorageTestCase(StorageBaseTestCase):
100 """ Tests for Storage """135 """ Tests for Storage """
101136
102 def test_storage_page(self):137 def _get_space_by_directory(self, dir_name):
103 """ Check whether Storage page is available """138 if dir_name == 'Music':
104 self.assertThat(self.storage_page, NotEquals(None))139 location = GLib.get_user_special_dir(
140 GLib.UserDirectory.DIRECTORY_MUSIC
141 )
142 elif dir_name == 'Videos':
143 location = GLib.get_user_special_dir(
144 GLib.UserDirectory.DIRECTORY_VIDEOS
145 )
146 elif dir_name == 'Pictures':
147 location = GLib.get_user_special_dir(
148 GLib.UserDirectory.DIRECTORY_PICTURES
149 )
150 else:
151 raise ValueError(
152 '{} directory not handled by this fuction, you need to enhance'
153 ' this function to handle that directory.'.format(dir_name)
154 )
155
156 if not os.path.exists(location):
157 self.skipTest('glib directory {} does not exist'.format(dir_name))
158
159 output = subprocess.check_output(['du', '--block-size=1', location])
160 disk_space = output.split()[len(output.split()) - 2]
161 return disk_space
105162
106 def test_disk(self):163 def test_disk(self):
107 """ Checks whether disk item is available """164 """ Checks whether disk item is available """
108 sleep(5)165 disk_item = self.storage_page.wait_select_single(objectName='diskItem')
109 disk_item = self.storage_page.select_single(objectName='diskItem')166 self.assertThat(disk_item.text, Equals('Total storage'))
110 self.assertThat(disk_item, NotEquals(None))
111 self.assertThat(disk_item.text, Equals(_('Total storage')))
112167
113 def test_space(self):168 def test_space(self):
114 """ Checks whether storage item is available """169 """ Checks whether storage item is available """
@@ -118,17 +173,49 @@
118 """ Checks storage item """173 """ Checks storage item """
119 self.assert_space_item('usedByUbuntuItem', _('Used by Ubuntu'))174 self.assert_space_item('usedByUbuntuItem', _('Used by Ubuntu'))
120175
121 def test_space_movies(self):176 @unittest.skip(
122 """ Checks whether space item is available """177 'Disk calculation can take a while depending on different factors '
123 self.assert_space_item('moviesItem', _('Videos'))178 'we dont want to wait for it to calculate.'
124179 )
125 def test_space_audio(self):180 def test_space_used_by_movies(self):
126 """ Checks whether space item is available """181 """ Checks whether space shown to be used by movies is
127 self.assert_space_item('audioItem', _('Audio'))182 correct. """
128183 movie_space = self._get_space_by_directory('Videos')
129 def test_space_pictures(self):184 movie_space_in_ui = self.get_storage_space_used_by_category(
130 """ Checks whether space item is available """185 'moviesItem'
131 self.assert_space_item('picturesItem', _('Pictures'))186 )
187
188 self.assertThat(movie_space_in_ui, Eventually(Equals(movie_space)))
189
190 @unittest.skip(
191 'Disk calculation can take a while depending on different factors '
192 'we dont want to wait for it to calculate.'
193 )
194 def test_space_used_by_music(self):
195 """ Checks whether space shown to be used by music is
196 correct. """
197 music_space = self._get_space_by_directory('Music')
198 music_space_in_ui = self.get_storage_space_used_by_category(
199 'audioItem'
200 )
201
202 self.assertThat(music_space_in_ui, Eventually(Equals(music_space)))
203
204 @unittest.skip(
205 'Disk calculation can take a while depending on different factors '
206 'we dont want to wait for it to calculate.'
207 )
208 def test_space_used_by_pictures(self):
209 """ Checks whether space shown to be used by pictures is
210 correct. """
211 pictures_space = self._get_space_by_directory('Pictures')
212 pictures_space_in_ui = self.get_storage_space_used_by_category(
213 'picturesItem'
214 )
215
216 self.assertThat(
217 pictures_space_in_ui, Eventually(Equals(pictures_space))
218 )
132219
133 def test_space_other_files(self):220 def test_space_other_files(self):
134 """ Checks whether space item is available """221 """ Checks whether space item is available """
@@ -149,7 +236,6 @@
149class LicenseTestCase(LicenseBaseTestCase):236class LicenseTestCase(LicenseBaseTestCase):
150 """ Tests for Licenses """237 """ Tests for Licenses """
151238
152 @expectedFailure
153 def test_licenses_page(self):239 def test_licenses_page(self):
154 """ Check whether Storage page is available """240 """ Check whether Storage page is available """
155 self.assertThat(self.licenses_page, NotEquals(None))241 self.assertThat(self.licenses_page.active, Eventually(Equals(True)))
156242
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_search.py'
--- tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-03-10 11:24:08 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-04-08 12:01:45 +0000
@@ -6,7 +6,8 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8from autopilot.introspection.dbus import StateNotFoundError8from autopilot.introspection.dbus import StateNotFoundError
9from testtools.matchers import Equals, NotEquals9from testtools.matchers import Equals
10from autopilot.matchers import Eventually
1011
11from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase12from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
12from ubuntu_system_settings.utils.i18n import ugettext as _13from ubuntu_system_settings.utils.i18n import ugettext as _
@@ -21,22 +22,25 @@
21 def setUp(self):22 def setUp(self):
22 super(SearchTestCases, self).setUp()23 super(SearchTestCases, self).setUp()
2324
24 def test_search(self):25 def _get_entry_component(self, name):
26 return self.main_view.wait_select_single(
27 objectName='entryComponent-' + name
28 )
29
30 def _type_into_search_box(self, text):
31 search_box = self.main_view.select_single(
32 objectName='searchTextField'
33 )
34 self.scroll_to_and_click(search_box)
35 self.keyboard.type(_(text))
36 self.assertThat(search_box.text, Eventually(Equals(text)))
37
38 def test_search_filter_results(self):
25 """ Checks whether Search box actually filters the results """39 """ Checks whether Search box actually filters the results """
26 # Select search text field40 self._type_into_search_box('Sound')
27 search = self.main_view.select_single(objectName='searchTextField')41 sound_icon = self._get_entry_component('sound')
28 self.assertThat(search, NotEquals(None))42
29 # Move to text field43 self.assertThat(sound_icon.visible, Eventually(Equals(True)))
30 self.scroll_to_and_click(search)44 self.assertRaises(
31 # Filter by string45 StateNotFoundError, self._get_entry_component, 'background'
32 self.keyboard.type(_('Sound'))46 )
33 # Search component
34 sound = self.main_view.select_single(objectName='entryComponent-sound')
35 self.assertThat(sound, NotEquals(None))
36 try:
37 background = self.main_view.select_single(
38 objectName='entryComponent-background'
39 )
40 except StateNotFoundError:
41 background = None
42 self.assertThat(background, Equals(None))

Subscribers

People subscribed via source and target branches