OLD | NEW |
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 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 def ChangedContents(self): | 103 def ChangedContents(self): |
104 return self._changed_contents | 104 return self._changed_contents |
105 | 105 |
106 def NewContents(self): | 106 def NewContents(self): |
107 return self._new_contents | 107 return self._new_contents |
108 | 108 |
109 def LocalPath(self): | 109 def LocalPath(self): |
110 return self._local_path | 110 return self._local_path |
111 | 111 |
| 112 def AbsoluteLocalPath(self): |
| 113 return self._local_path |
| 114 |
112 def rfind(self, p): | 115 def rfind(self, p): |
113 """os.path.basename is called on MockFile so we need an rfind method.""" | 116 """os.path.basename is called on MockFile so we need an rfind method.""" |
114 return self._local_path.rfind(p) | 117 return self._local_path.rfind(p) |
115 | 118 |
116 def __getitem__(self, i): | 119 def __getitem__(self, i): |
117 """os.path.basename is called on MockFile so we need a get method.""" | 120 """os.path.basename is called on MockFile so we need a get method.""" |
118 return self._local_path[i] | 121 return self._local_path[i] |
119 | 122 |
120 | 123 |
121 class MockAffectedFile(MockFile): | 124 class MockAffectedFile(MockFile): |
122 def AbsoluteLocalPath(self): | 125 def AbsoluteLocalPath(self): |
123 return self._local_path | 126 return self._local_path |
124 | 127 |
125 | 128 |
126 class MockChange(object): | 129 class MockChange(object): |
127 """Mock class for Change class. | 130 """Mock class for Change class. |
128 | 131 |
129 This class can be used in presubmit unittests to mock the query of the | 132 This class can be used in presubmit unittests to mock the query of the |
130 current change. | 133 current change. |
131 """ | 134 """ |
132 | 135 |
133 def __init__(self, changed_files): | 136 def __init__(self, changed_files): |
134 self._changed_files = changed_files | 137 self._changed_files = changed_files |
135 | 138 |
136 def LocalPaths(self): | 139 def LocalPaths(self): |
137 return self._changed_files | 140 return self._changed_files |
OLD | NEW |