Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: chrome/common/extensions/docs/server2/test_patcher.py

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: add executable bits for tests Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698