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

Side by Side Diff: PRESUBMIT_test_mocks.py

Issue 2296783002: Adds new logging type SYSLOG which logs to the system log. (Closed)
Patch Set: Moved the SYSLOG code to a separate file. Created 4 years, 3 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
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.platform = sys.platform
24 self.subprocess = subprocess 25 self.subprocess = subprocess
25 self.files = [] 26 self.files = []
26 self.is_committing = False 27 self.is_committing = False
27 self.change = MockChange([]) 28 self.change = MockChange([])
28 29
29 def AffectedFiles(self, file_filter=None, include_deletes=False): 30 def AffectedFiles(self, file_filter=None, include_deletes=False):
30 return self.files 31 return self.files
31 32
32 def AffectedSourceFiles(self, file_filter=None): 33 def AffectedSourceFiles(self, file_filter=None):
33 return self.files 34 return self.files
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return self._local_path 115 return self._local_path
115 116
116 def rfind(self, p): 117 def rfind(self, p):
117 """os.path.basename is called on MockFile so we need an rfind method.""" 118 """os.path.basename is called on MockFile so we need an rfind method."""
118 return self._local_path.rfind(p) 119 return self._local_path.rfind(p)
119 120
120 def __getitem__(self, i): 121 def __getitem__(self, i):
121 """os.path.basename is called on MockFile so we need a get method.""" 122 """os.path.basename is called on MockFile so we need a get method."""
122 return self._local_path[i] 123 return self._local_path[i]
123 124
125 def __len__(self):
126 """os.path.basename is called on MockFile so we need a len method."""
127 return len(self._local_path)
128
124 129
125 class MockAffectedFile(MockFile): 130 class MockAffectedFile(MockFile):
126 def AbsoluteLocalPath(self): 131 def AbsoluteLocalPath(self):
127 return self._local_path 132 return self._local_path
128 133
129 134
130 class MockChange(object): 135 class MockChange(object):
131 """Mock class for Change class. 136 """Mock class for Change class.
132 137
133 This class can be used in presubmit unittests to mock the query of the 138 This class can be used in presubmit unittests to mock the query of the
134 current change. 139 current change.
135 """ 140 """
136 141
137 def __init__(self, changed_files): 142 def __init__(self, changed_files):
138 self._changed_files = changed_files 143 self._changed_files = changed_files
139 144
140 def LocalPaths(self): 145 def LocalPaths(self):
141 return self._changed_files 146 return self._changed_files
OLDNEW
« no previous file with comments | « PRESUBMIT_test.py ('k') | base/BUILD.gn » ('j') | base/syslog_logging.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698