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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 rietveld.Rietveld.parse_svn_properties(u'', 'foo')) | 281 rietveld.Rietveld.parse_svn_properties(u'', 'foo')) |
282 | 282 |
283 try: | 283 try: |
284 rietveld.Rietveld.parse_svn_properties(u'\n', 'foo') | 284 rietveld.Rietveld.parse_svn_properties(u'\n', 'foo') |
285 self.fail() | 285 self.fail() |
286 except rietveld.patch.UnsupportedPatchFormat, e: | 286 except rietveld.patch.UnsupportedPatchFormat, e: |
287 self.assertEquals('foo', e.filename) | 287 self.assertEquals('foo', e.filename) |
288 # TODO(maruel): Change with no diff, only svn property change: | 288 # TODO(maruel): Change with no diff, only svn property change: |
289 # http://codereview.chromium.org/6462019/ | 289 # http://codereview.chromium.org/6462019/ |
290 | 290 |
| 291 def test_get_patch_moved(self): |
| 292 output = ( |
| 293 '{\n' |
| 294 ' "files":\n' |
| 295 ' {\n' |
| 296 ' "file_a":\n' |
| 297 ' {\n' |
| 298 ' "status": "A+",\n' |
| 299 ' "is_binary": false,\n' |
| 300 ' "num_chunks": 1,\n' |
| 301 ' "id": 789\n' |
| 302 ' }\n' |
| 303 ' }\n' |
| 304 '}\n') |
| 305 diff = ( |
| 306 '--- /dev/null\n' |
| 307 '+++ file_a\n' |
| 308 '@@ -0,0 +1 @@\n' |
| 309 '+foo\n') |
| 310 r = rietveld.Rietveld('url', 'email', 'password') |
| 311 def _send(args, **kwargs): |
| 312 if args == '/api/123/456': |
| 313 return output |
| 314 elif args == '/download/issue123_456_789.diff': |
| 315 return diff |
| 316 else: |
| 317 self.fail() |
| 318 r._send = _send |
| 319 patches = r.get_patch(123, 456) |
| 320 self.assertEquals(diff, patches.patches[0].get()) |
| 321 self.assertEquals([], patches.patches[0].svn_properties) |
| 322 |
291 | 323 |
292 if __name__ == '__main__': | 324 if __name__ == '__main__': |
293 logging.basicConfig(level=logging.ERROR) | 325 logging.basicConfig(level=logging.ERROR) |
294 unittest.main() | 326 unittest.main() |
OLD | NEW |