| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright 2014 The LUCI Authors. All rights reserved. | 2 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Base class for handlers_*_test.py""" | 6 """Base class for handlers_*_test.py""" |
| 7 | 7 |
| 8 import base64 | 8 import base64 |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 'started_ts': 1410990411.111, | 158 'started_ts': 1410990411.111, |
| 159 }, | 159 }, |
| 160 'version': '123', | 160 'version': '123', |
| 161 } | 161 } |
| 162 response = self.app.post_json( | 162 response = self.app.post_json( |
| 163 '/swarming/api/v1/bot/handshake', | 163 '/swarming/api/v1/bot/handshake', |
| 164 params=params).json | 164 params=params).json |
| 165 self.bot_version = response['bot_version'] | 165 self.bot_version = response['bot_version'] |
| 166 params['version'] = self.bot_version | 166 params['version'] = self.bot_version |
| 167 params['state']['bot_group_cfg_version'] = response['bot_group_cfg_version'] | 167 params['state']['bot_group_cfg_version'] = response['bot_group_cfg_version'] |
| 168 # A bit hackish but fine for unit testing purpose. |
| 169 if response.get('bot_config'): |
| 170 params['bot_config'] = response['bot_config'] |
| 168 return params | 171 return params |
| 169 | 172 |
| 170 def bot_poll(self, bot='bot1'): | 173 def bot_poll(self, bot='bot1'): |
| 171 """Simulates a bot that polls for task.""" | 174 """Simulates a bot that polls for task.""" |
| 172 params = self.do_handshake(bot) | 175 params = self.do_handshake(bot) |
| 173 return self.post_json('/swarming/api/v1/bot/poll', params) | 176 return self.post_json('/swarming/api/v1/bot/poll', params) |
| 174 | 177 |
| 175 def bot_complete_task(self, **kwargs): | 178 def bot_complete_task(self, **kwargs): |
| 176 # Emulate an isolated task. | 179 # Emulate an isolated task. |
| 177 params = { | 180 params = { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 276 |
| 274 def client_create_task_raw(self, properties=None, **kwargs): | 277 def client_create_task_raw(self, properties=None, **kwargs): |
| 275 """Creates a raw command TaskRequest via the Cloud Endpoints API.""" | 278 """Creates a raw command TaskRequest via the Cloud Endpoints API.""" |
| 276 properties = (properties or {}).copy() | 279 properties = (properties or {}).copy() |
| 277 properties['command'] = ['python', 'run_test.py'] | 280 properties['command'] = ['python', 'run_test.py'] |
| 278 return self._client_create_task(properties, **kwargs) | 281 return self._client_create_task(properties, **kwargs) |
| 279 | 282 |
| 280 def client_get_results(self, task_id): | 283 def client_get_results(self, task_id): |
| 281 return self.endpoint_call( | 284 return self.endpoint_call( |
| 282 handlers_endpoints.SwarmingTaskService, 'result', {'task_id': task_id}) | 285 handlers_endpoints.SwarmingTaskService, 'result', {'task_id': task_id}) |
| OLD | NEW |