OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Environment setup and teardown for remote devices.""" | 5 """Environment setup and teardown for remote devices.""" |
6 | 6 |
7 import distutils.version | 7 import distutils.version |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 self._collect = True | 176 self._collect = True |
177 else: | 177 else: |
178 self._trigger = args.trigger | 178 self._trigger = args.trigger |
179 self._collect = args.collect | 179 self._collect = args.collect |
180 | 180 |
181 def SetUp(self): | 181 def SetUp(self): |
182 """Set up the test environment.""" | 182 """Set up the test environment.""" |
183 os.environ['APPURIFY_API_PROTO'] = self._api_protocol | 183 os.environ['APPURIFY_API_PROTO'] = self._api_protocol |
184 os.environ['APPURIFY_API_HOST'] = self._api_address | 184 os.environ['APPURIFY_API_HOST'] = self._api_address |
185 os.environ['APPURIFY_API_PORT'] = self._api_port | 185 os.environ['APPURIFY_API_PORT'] = self._api_port |
| 186 os.environ['APPURIFY_STATUS_BASE_URL'] = 'none' |
186 self._GetAccessToken() | 187 self._GetAccessToken() |
187 if self._trigger: | 188 if self._trigger: |
188 self._SelectDevice() | 189 self._SelectDevice() |
189 | 190 |
190 def TearDown(self): | 191 def TearDown(self): |
191 """Teardown the test environment.""" | 192 """Teardown the test environment.""" |
192 self._RevokeAccessToken() | 193 self._RevokeAccessToken() |
193 | 194 |
194 def __enter__(self): | 195 def __enter__(self): |
195 """Set up the test run when used as a context manager.""" | 196 """Set up the test run when used as a context manager.""" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 def _GetDeviceList(self): | 296 def _GetDeviceList(self): |
296 with appurify_sanitized.SanitizeLogging(self._verbose_count, | 297 with appurify_sanitized.SanitizeLogging(self._verbose_count, |
297 logging.WARNING): | 298 logging.WARNING): |
298 dev_list_res = appurify_sanitized.api.devices_list(self._access_token) | 299 dev_list_res = appurify_sanitized.api.devices_list(self._access_token) |
299 remote_device_helper.TestHttpResponse(dev_list_res, | 300 remote_device_helper.TestHttpResponse(dev_list_res, |
300 'Unable to generate access token.') | 301 'Unable to generate access token.') |
301 return dev_list_res.json()['response'] | 302 return dev_list_res.json()['response'] |
302 | 303 |
303 def _NoDeviceFound(self): | 304 def _NoDeviceFound(self): |
304 self._PrintAvailableDevices(self._GetDeviceList()) | 305 self._PrintAvailableDevices(self._GetDeviceList()) |
305 raise remote_device_helper.RemoteDeviceError('No device found.') | 306 raise remote_device_helper.RemoteDeviceError( |
| 307 'No device found.', is_infra_error=True) |
306 | 308 |
307 @property | 309 @property |
308 def collect(self): | 310 def collect(self): |
309 return self._collect | 311 return self._collect |
310 | 312 |
311 @property | 313 @property |
312 def device_type_id(self): | 314 def device_type_id(self): |
313 return self._device['device_type_id'] | 315 return self._device['device_type_id'] |
314 | 316 |
315 @property | 317 @property |
(...skipping 25 matching lines...) Expand all Loading... |
341 def trigger(self): | 343 def trigger(self): |
342 return self._trigger | 344 return self._trigger |
343 | 345 |
344 @property | 346 @property |
345 def verbose_count(self): | 347 def verbose_count(self): |
346 return self._verbose_count | 348 return self._verbose_count |
347 | 349 |
348 @property | 350 @property |
349 def device_type(self): | 351 def device_type(self): |
350 return self._device_type | 352 return self._device_type |
OLD | NEW |