| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS 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 """Module containing a fake au worker class.""" | 5 """Module containing a fake au worker class.""" |
| 6 | 6 |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 import cros_build_lib as cros_lib |
| 10 |
| 9 import au_worker | 11 import au_worker |
| 10 | 12 |
| 11 class DummyAUWorker(au_worker.AUWorker): | 13 class DummyAUWorker(au_worker.AUWorker): |
| 12 """AU worker that emulates work for an au_worker without actually doing work. | 14 """AU worker that emulates work for an au_worker without actually doing work. |
| 13 | 15 |
| 14 Collects different updates that would be generated that can be obtained | 16 Collects different updates that would be generated that can be obtained |
| 15 from the class object delta_list. | 17 from the class object delta_list. |
| 16 """ | 18 """ |
| 17 | 19 |
| 18 # Class variable that stores the list of payloads that would be needed. | 20 # Class variable that stores the list of payloads that would be needed. |
| 19 delta_list = {} | 21 delta_list = {} |
| 20 | 22 |
| 21 def __init__(self, options, test_results_root): | 23 def __init__(self, options, test_results_root): |
| 22 au_worker.AUWorker.__init__(self, options, test_results_root) | 24 super(DummyAUWorker, self).__init__(options, test_results_root) |
| 23 self.au_type = options.type | 25 self.au_type = options.type |
| 24 | 26 |
| 25 def PrepareBase(self, image_path): | 27 def PrepareBase(self, image_path): |
| 26 """Copy how the actual worker would prepare the base image.""" | 28 """Copy how the actual worker would prepare the base image.""" |
| 27 if self.au_type == 'vm': | 29 if self.au_type == 'vm': |
| 28 self.PrepareVMBase(image_path) | 30 self.PrepareVMBase(image_path) |
| 29 else: | 31 else: |
| 30 self.PrepareRealBase(image_path) | 32 self.PrepareRealBase(image_path) |
| 31 | 33 |
| 32 def UpdateImage(self, image_path, src_image_path='', stateful_change='old', | 34 def UpdateImage(self, image_path, src_image_path='', stateful_change='old', |
| 33 proxy_port=None, private_key_path=None): | 35 proxy_port=None, private_key_path=None): |
| 34 """Emulate Update and record the update payload in delta_list.""" | 36 """Emulate Update and record the update payload in delta_list.""" |
| 35 if self.au_type == 'vm' and src_image_path and self._first_update: | 37 if self.au_type == 'vm' and src_image_path and self._first_update: |
| 36 src_image_path = self.vm_image_path | 38 src_image_path = self.vm_image_path |
| 37 self._first_update = False | 39 self._first_update = False |
| 38 | 40 |
| 39 # Generate a value that combines delta with private key path. | 41 # Generate a value that combines delta with private key path. |
| 40 val = src_image_path | 42 val = src_image_path |
| 41 if private_key_path: val = '%s+%s' % (val, private_key_path) | 43 if private_key_path: val = '%s+%s' % (val, private_key_path) |
| 42 if not self.delta_list.has_key(image_path): | 44 if not self.delta_list.has_key(image_path): |
| 43 self.delta_list[image_path] = set([val]) | 45 self.delta_list[image_path] = set([val]) |
| 44 else: | 46 else: |
| 45 self.delta_list[image_path].add(val) | 47 self.delta_list[image_path].add(val) |
| OLD | NEW |