| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from future import Future |
| 6 from patcher import Patcher |
| 7 |
| 8 class TestPatcher(Patcher): |
| 9 def __init__(self, version, patched_files, patch_data, assert_binary=False): |
| 10 self._version = version |
| 11 self._patched_files = patched_files |
| 12 self._patch_data = patch_data |
| 13 self._assert_binary = assert_binary |
| 14 |
| 15 self.get_version_count = 0 |
| 16 self.get_patched_files_count = 0 |
| 17 self.apply_count = 0 |
| 18 |
| 19 def GetVersion(self): |
| 20 self.get_version_count += 1 |
| 21 return self._version |
| 22 |
| 23 def GetPatchedFiles(self, version=None): |
| 24 self.get_patched_files_count += 1 |
| 25 return self._patched_files |
| 26 |
| 27 def Apply(self, paths, file_system, binary, version=None): |
| 28 if self._assert_binary: |
| 29 assert binary |
| 30 self.apply_count += 1 |
| 31 try: |
| 32 return Future(value={path: self._patch_data[path] for path in paths}) |
| 33 except KeyError: |
| 34 raise FileNotFoundError('One of %s is deleted in the patch.' % paths) |
| OLD | NEW |