OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for rietveld.py.""" | 6 """Unit tests for rietveld.py.""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ] | 173 ] |
174 patches = self.rietveld.get_patch(123, 456) | 174 patches = self.rietveld.get_patch(123, 456) |
175 self.assertEquals(1, len(patches.patches)) | 175 self.assertEquals(1, len(patches.patches)) |
176 self._check_patch( | 176 self._check_patch( |
177 patches.patches[0], | 177 patches.patches[0], |
178 '__init__.py', | 178 '__init__.py', |
179 RAW.CRAP_ONLY, | 179 RAW.CRAP_ONLY, |
180 is_new=True) | 180 is_new=True) |
181 | 181 |
182 def test_delete(self): | 182 def test_delete(self): |
| 183 name = 'tools/clang_check/README.chromium' |
183 self.requests = [ | 184 self.requests = [ |
184 ('/api/123/456', _api({'file_a': _file('D')})), | 185 ('/api/123/456', _api({name: _file('D')})), |
| 186 ('/download/issue123_456_789.diff', RAW.DELETE), |
185 ] | 187 ] |
186 patches = self.rietveld.get_patch(123, 456) | 188 patches = self.rietveld.get_patch(123, 456) |
187 self.assertEquals(1, len(patches.patches)) | 189 self.assertEquals(1, len(patches.patches)) |
188 self._check_patch(patches.patches[0], 'file_a', None, is_delete=True) | 190 self._check_patch(patches.patches[0], name, None, is_delete=True) |
189 | 191 |
190 def test_m_plus(self): | 192 def test_m_plus(self): |
191 properties = '\nAdded: svn:eol-style\n + LF\n' | 193 properties = '\nAdded: svn:eol-style\n + LF\n' |
192 self.requests = [ | 194 self.requests = [ |
193 ('/api/123/456', | 195 ('/api/123/456', |
194 _api({'chrome/file.cc': _file('M+', property_changes=properties)})), | 196 _api({'chrome/file.cc': _file('M+', property_changes=properties)})), |
195 ('/download/issue123_456_789.diff', RAW.PATCH), | 197 ('/download/issue123_456_789.diff', RAW.PATCH), |
196 ] | 198 ] |
197 patches = self.rietveld.get_patch(123, 456) | 199 patches = self.rietveld.get_patch(123, 456) |
198 self.assertEquals(1, len(patches.patches)) | 200 self.assertEquals(1, len(patches.patches)) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 self.fail() | 278 self.fail() |
277 except rietveld.patch.UnsupportedPatchFormat, e: | 279 except rietveld.patch.UnsupportedPatchFormat, e: |
278 self.assertEquals('foo', e.filename) | 280 self.assertEquals('foo', e.filename) |
279 # TODO(maruel): Change with no diff, only svn property change: | 281 # TODO(maruel): Change with no diff, only svn property change: |
280 # http://codereview.chromium.org/6462019/ | 282 # http://codereview.chromium.org/6462019/ |
281 | 283 |
282 | 284 |
283 if __name__ == '__main__': | 285 if __name__ == '__main__': |
284 logging.basicConfig(level=logging.ERROR) | 286 logging.basicConfig(level=logging.ERROR) |
285 unittest.main() | 287 unittest.main() |
OLD | NEW |