summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/server2/test_patcher.py
diff options
context:
space:
mode:
authorkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-13 14:15:06 +0000
committerkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-13 14:15:06 +0000
commit39824c52f57acdc5adc625b7c5900c89fc42e351 (patch)
treee6a25f75c3f1034d5429497beac96aa672989d9d /chrome/common/extensions/docs/server2/test_patcher.py
parente871964c45f8edd10d480a804d8889eb7c0867e7 (diff)
downloadchromium_src-39824c52f57acdc5adc625b7c5900c89fc42e351.zip
chromium_src-39824c52f57acdc5adc625b7c5900c89fc42e351.tar.gz
chromium_src-39824c52f57acdc5adc625b7c5900c89fc42e351.tar.bz2
This change would make it easier for docs reviewers to preview patched docs
without locally patching in or asking patch author to stage it on a workstation. Patched docs will be available at https://developer.chrome.com/_patch/issue_number/extensions/... after this CL is landed and deployed. Note that this doesn't work for patches that involve server-side changes. R=kalman@chromium.org BUG=234022 Review URL: https://codereview.chromium.org/14125010 Patch from Fang Jue <fangjue23303@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/server2/test_patcher.py')
-rw-r--r--chrome/common/extensions/docs/server2/test_patcher.py34
1 files changed, 34 insertions, 0 deletions
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 0000000..faa491f
--- /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)