Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
PRESUBMIT_test_mocks.MockFile Class Reference
Inheritance diagram for PRESUBMIT_test_mocks.MockFile:
PRESUBMIT_test_mocks.MockAffectedFile

Public Member Functions

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

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__()

def 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__()

def 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__()

def 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()

def 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()

def 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()

def 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()

def 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()

def 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()

def 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
static uword NewContents(intptr_t capacity)

◆ OldContents()

def 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()

def 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()

def 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

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