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

Side by Side Diff: PRESUBMIT_test_mocks.py

Issue 1846103005: Reland of Include isolate.py in data for Android unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: even more cautious Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « PRESUBMIT_test.py ('k') | build/android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import os 6 import os
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 10
11 11
12 class MockInputApi(object): 12 class MockInputApi(object):
13 """Mock class for the InputApi class. 13 """Mock class for the InputApi class.
14 14
15 This class can be used for unittests for presubmit by initializing the files 15 This class can be used for unittests for presubmit by initializing the files
16 attribute as the list of changed files. 16 attribute as the list of changed files.
17 """ 17 """
18 18
19 def __init__(self): 19 def __init__(self):
20 self.json = json 20 self.json = json
21 self.re = re 21 self.re = re
22 self.os_path = os.path 22 self.os_path = os.path
23 self.python_executable = sys.executable 23 self.python_executable = sys.executable
24 self.subprocess = subprocess 24 self.subprocess = subprocess
25 self.files = [] 25 self.files = []
26 self.is_committing = False 26 self.is_committing = False
27 self.change = MockChange([]) 27 self.change = MockChange([])
28 28
29 def AffectedFiles(self, file_filter=None): 29 def AffectedFiles(self, file_filter=None, include_deletes=False):
30 return self.files 30 return self.files
31 31
32 def AffectedSourceFiles(self, file_filter=None): 32 def AffectedSourceFiles(self, file_filter=None):
33 return self.files 33 return self.files
34 34
35 def LocalPaths(self): 35 def LocalPaths(self):
36 return self.files 36 return self.files
37 37
38 def PresubmitLocalPath(self): 38 def PresubmitLocalPath(self):
39 return os.path.dirname(__file__) 39 return os.path.dirname(__file__)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 self.type = 'promptOrNotify' 85 self.type = 'promptOrNotify'
86 86
87 87
88 class MockFile(object): 88 class MockFile(object):
89 """Mock class for the File class. 89 """Mock class for the File class.
90 90
91 This class can be used to form the mock list of changed files in 91 This class can be used to form the mock list of changed files in
92 MockInputApi for presubmit unittests. 92 MockInputApi for presubmit unittests.
93 """ 93 """
94 94
95 def __init__(self, local_path, new_contents): 95 def __init__(self, local_path, new_contents, action='A'):
96 self._local_path = local_path 96 self._local_path = local_path
97 self._new_contents = new_contents 97 self._new_contents = new_contents
98 self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)] 98 self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
99 self._action = action
99 100
100 def Action(self): 101 def Action(self):
101 return 'A' # TODO(dbeam): feel free to change if your test actually uses. 102 return self._action
102 103
103 def ChangedContents(self): 104 def ChangedContents(self):
104 return self._changed_contents 105 return self._changed_contents
105 106
106 def NewContents(self): 107 def NewContents(self):
107 return self._new_contents 108 return self._new_contents
108 109
109 def LocalPath(self): 110 def LocalPath(self):
110 return self._local_path 111 return self._local_path
111 112
(...skipping 19 matching lines...) Expand all
131 132
132 This class can be used in presubmit unittests to mock the query of the 133 This class can be used in presubmit unittests to mock the query of the
133 current change. 134 current change.
134 """ 135 """
135 136
136 def __init__(self, changed_files): 137 def __init__(self, changed_files):
137 self._changed_files = changed_files 138 self._changed_files = changed_files
138 139
139 def LocalPaths(self): 140 def LocalPaths(self):
140 return self._changed_files 141 return self._changed_files
OLDNEW
« no previous file with comments | « PRESUBMIT_test.py ('k') | build/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698