Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
PRESUBMIT_test_mocks.MockFile Class Reference
Inheritance diagram for PRESUBMIT_test_mocks.MockFile:
PRESUBMIT_test_mocks.MockAffectedFile

Public Member Functions

 __init__ (self, local_path, new_contents, old_contents=None, action='A', scm_diff=None)
 
 Action (self)
 
 ChangedContents (self)
 
 NewContents (self)
 
 LocalPath (self)
 
 AbsoluteLocalPath (self)
 
 GenerateScmDiff (self)
 
 OldContents (self)
 
 rfind (self, p)
 
 __getitem__ (self, i)
 
 __len__ (self)
 
 replace (self, altsep, sep)
 

Protected Attributes

 _local_path
 
 _new_contents
 
 _changed_contents
 
 _action
 
 _scm_diff
 
 _old_contents
 

Detailed Description

Mock class for the File class.

This class can be used to form the mock list of changed files in
MockInputApi for presubmit unittests.

Definition at line 198 of file PRESUBMIT_test_mocks.py.

Constructor & Destructor Documentation

◆ __init__()

PRESUBMIT_test_mocks.MockFile.__init__ (   self,
  local_path,
  new_contents,
  old_contents = None,
  action = 'A',
  scm_diff = None 
)

Definition at line 205 of file PRESUBMIT_test_mocks.py.

206 scm_diff=None):
207 self._local_path = local_path
208 self._new_contents = new_contents
209 self._changed_contents = [(i + 1, l)
210 for i, l in enumerate(new_contents)]
211 self._action = action
212 if scm_diff:
213 self._scm_diff = scm_diff
214 else:
215 self._scm_diff = (
216 "--- /dev/null\n+++ %s\n@@ -0,0 +1,%d @@\n" %
217 (local_path, len(new_contents)))
218 for l in new_contents:
219 self._scm_diff += "+%s\n" % l
220 self._old_contents = old_contents
221

Member Function Documentation

◆ __getitem__()

PRESUBMIT_test_mocks.MockFile.__getitem__ (   self,
  i 
)
os.path.basename is called on MockFile so we need a get method.

Definition at line 247 of file PRESUBMIT_test_mocks.py.

247 def __getitem__(self, i):
248 """os.path.basename is called on MockFile so we need a get method."""
249 return self._local_path[i]
250

◆ __len__()

PRESUBMIT_test_mocks.MockFile.__len__ (   self)
os.path.basename is called on MockFile so we need a len method.

Definition at line 251 of file PRESUBMIT_test_mocks.py.

251 def __len__(self):
252 """os.path.basename is called on MockFile so we need a len method."""
253 return len(self._local_path)
254

◆ AbsoluteLocalPath()

PRESUBMIT_test_mocks.MockFile.AbsoluteLocalPath (   self)

Reimplemented in PRESUBMIT_test_mocks.MockAffectedFile.

Definition at line 234 of file PRESUBMIT_test_mocks.py.

234 def AbsoluteLocalPath(self):
235 return self._local_path
236

◆ Action()

PRESUBMIT_test_mocks.MockFile.Action (   self)

Definition at line 222 of file PRESUBMIT_test_mocks.py.

222 def Action(self):
223 return self._action
224

◆ ChangedContents()

PRESUBMIT_test_mocks.MockFile.ChangedContents (   self)

Definition at line 225 of file PRESUBMIT_test_mocks.py.

225 def ChangedContents(self):
226 return self._changed_contents
227

◆ GenerateScmDiff()

PRESUBMIT_test_mocks.MockFile.GenerateScmDiff (   self)

Definition at line 237 of file PRESUBMIT_test_mocks.py.

237 def GenerateScmDiff(self):
238 return self._scm_diff
239

◆ LocalPath()

PRESUBMIT_test_mocks.MockFile.LocalPath (   self)

Definition at line 231 of file PRESUBMIT_test_mocks.py.

231 def LocalPath(self):
232 return self._local_path
233

◆ NewContents()

PRESUBMIT_test_mocks.MockFile.NewContents (   self)

Definition at line 228 of file PRESUBMIT_test_mocks.py.

228 def NewContents(self):
229 return self._new_contents
230

◆ OldContents()

PRESUBMIT_test_mocks.MockFile.OldContents (   self)

Definition at line 240 of file PRESUBMIT_test_mocks.py.

240 def OldContents(self):
241 return self._old_contents
242

◆ replace()

PRESUBMIT_test_mocks.MockFile.replace (   self,
  altsep,
  sep 
)
os.path.basename is called on MockFile so we need a replace method.

Definition at line 255 of file PRESUBMIT_test_mocks.py.

255 def replace(self, altsep, sep):
256 """os.path.basename is called on MockFile so we need a replace method."""
257 return self._local_path.replace(altsep, sep)
258
259

◆ rfind()

PRESUBMIT_test_mocks.MockFile.rfind (   self,
  p 
)
os.path.basename is called on MockFile so we need an rfind method.

Definition at line 243 of file PRESUBMIT_test_mocks.py.

243 def rfind(self, p):
244 """os.path.basename is called on MockFile so we need an rfind method."""
245 return self._local_path.rfind(p)
246

Member Data Documentation

◆ _action

PRESUBMIT_test_mocks.MockFile._action
protected

Definition at line 211 of file PRESUBMIT_test_mocks.py.

◆ _changed_contents

PRESUBMIT_test_mocks.MockFile._changed_contents
protected

Definition at line 209 of file PRESUBMIT_test_mocks.py.

◆ _local_path

PRESUBMIT_test_mocks.MockFile._local_path
protected

Definition at line 207 of file PRESUBMIT_test_mocks.py.

◆ _new_contents

PRESUBMIT_test_mocks.MockFile._new_contents
protected

Definition at line 208 of file PRESUBMIT_test_mocks.py.

◆ _old_contents

PRESUBMIT_test_mocks.MockFile._old_contents
protected

Definition at line 220 of file PRESUBMIT_test_mocks.py.

◆ _scm_diff

PRESUBMIT_test_mocks.MockFile._scm_diff
protected

Definition at line 213 of file PRESUBMIT_test_mocks.py.


The documentation for this class was generated from the following file: