~nik90/ubuntu-clock-app/new-bottom-edge

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_clock_app/fixture_setup.py

  • Committer: Nekhelesh Ramananthan
  • Date: 2016-02-25 23:10:10 UTC
  • mfrom: (442.2.1 trunk)
  • Revision ID: krnekhelesh@gmail.com-20160225231010-xb8ie0ruwmfhmq4u
MergedĀ lp:ubuntu-clock-app

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2014-2015 Canonical Ltd
2
 
#
3
 
# This file is part of Ubuntu Clock App
4
 
#
5
 
# Ubuntu Clock App is free software: you can redistribute it and/or modify
6
 
# it under the terms of the GNU General Public License version 3 as
7
 
# published by the Free Software Foundation.
8
 
#
9
 
# Ubuntu Clock App is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
# GNU General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU General Public License
15
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
 
17
 
"""Clock app autopilot fixtures."""
18
 
 
19
 
import fixtures
20
 
import logging
21
 
import subprocess
22
 
 
23
 
 
24
 
class LocationServiceTestEnvironment(fixtures.Fixture):
25
 
 
26
 
    def setUp(self):
27
 
        super(LocationServiceTestEnvironment, self).setUp()
28
 
        self._set_location_service_testing(True)
29
 
        self.addCleanup(self._set_location_service_testing, False)
30
 
 
31
 
    def _set_location_service_testing(self, test_mode):
32
 
        test = 'true' if test_mode else 'false'
33
 
        try:
34
 
            subprocess.check_call(
35
 
                'sudo setprop custom.location.testing {}'.format(test),
36
 
                shell=True)
37
 
            subprocess.check_call(
38
 
                'sudo restart ubuntu-location-service && '
39
 
                'restart ubuntu-location-service-trust-stored',
40
 
                shell=True)
41
 
        except subprocess.CalledProcessError:
42
 
            logger = logging.getLogger(__name__)
43
 
            logger.error('Unable to start location service in testing mode '
44
 
                         'tests may fail as a result.')