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