Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / test_patcher.py
blob6c4b906aa1332e36a4a323acf7505f224f5baa74
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.
5 from future import Future
6 from patcher import Patcher
8 class TestPatcher(Patcher):
9 def __init__(self, version, patched_files, patch_data):
10 self._version = version
11 self._patched_files = patched_files
12 self._patch_data = patch_data
14 self.get_version_count = 0
15 self.get_patched_files_count = 0
16 self.apply_count = 0
18 def GetVersion(self):
19 self.get_version_count += 1
20 return self._version
22 def GetPatchedFiles(self, version=None):
23 self.get_patched_files_count += 1
24 return self._patched_files
26 def Apply(self, paths, file_system, version=None):
27 self.apply_count += 1
28 try:
29 return Future(value=dict((path, self._patch_data[path])
30 for path in paths))
31 except KeyError:
32 raise FileNotFoundError('One of %s is deleted in the patch.' % paths)
34 def GetIdentity(self):
35 return self.__class__.__name__