| Index: chrome/common/extensions/docs/server2/test_patcher.py
|
| diff --git a/chrome/common/extensions/docs/server2/test_patcher.py b/chrome/common/extensions/docs/server2/test_patcher.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..faa491fae07218d08e1f179f91aa407b144afbc0
|
| --- /dev/null
|
| +++ b/chrome/common/extensions/docs/server2/test_patcher.py
|
| @@ -0,0 +1,34 @@
|
| +# Copyright 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from future import Future
|
| +from patcher import Patcher
|
| +
|
| +class TestPatcher(Patcher):
|
| + def __init__(self, version, patched_files, patch_data, assert_binary=False):
|
| + self._version = version
|
| + self._patched_files = patched_files
|
| + self._patch_data = patch_data
|
| + self._assert_binary = assert_binary
|
| +
|
| + self.get_version_count = 0
|
| + self.get_patched_files_count = 0
|
| + self.apply_count = 0
|
| +
|
| + def GetVersion(self):
|
| + self.get_version_count += 1
|
| + return self._version
|
| +
|
| + def GetPatchedFiles(self, version=None):
|
| + self.get_patched_files_count += 1
|
| + return self._patched_files
|
| +
|
| + def Apply(self, paths, file_system, binary, version=None):
|
| + if self._assert_binary:
|
| + assert binary
|
| + self.apply_count += 1
|
| + try:
|
| + return Future(value={path: self._patch_data[path] for path in paths})
|
| + except KeyError:
|
| + raise FileNotFoundError('One of %s is deleted in the patch.' % paths)
|
|
|