1
# Copyright (C) 2014-2015 Canonical Ltd
3
# This file is part of Ubuntu Clock App
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.
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.
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/>.
17
"""Clock app autopilot fixtures."""
24
class LocationServiceTestEnvironment(fixtures.Fixture):
27
super(LocationServiceTestEnvironment, self).setUp()
28
self._set_location_service_testing(True)
29
self.addCleanup(self._set_location_service_testing, False)
31
def _set_location_service_testing(self, test_mode):
32
test = 'true' if test_mode else 'false'
34
subprocess.check_call(
35
'sudo setprop custom.location.testing {}'.format(test),
37
subprocess.check_call(
38
'sudo restart ubuntu-location-service && '
39
'restart ubuntu-location-service-trust-stored',
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.')