Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tests/rietveld_test.py

Issue 8038056: Fix handling of file renames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rebase against HEAD Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/patch_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 self.assertEquals(p.filename, filename) 75 self.assertEquals(p.filename, filename)
76 self.assertEquals(p.source_filename, source_filename) 76 self.assertEquals(p.source_filename, source_filename)
77 self.assertEquals(p.is_binary, is_binary) 77 self.assertEquals(p.is_binary, is_binary)
78 self.assertEquals(p.is_delete, is_delete) 78 self.assertEquals(p.is_delete, is_delete)
79 if hasattr(p, 'is_git_diff'): 79 if hasattr(p, 'is_git_diff'):
80 self.assertEquals(p.is_git_diff, is_git_diff) 80 self.assertEquals(p.is_git_diff, is_git_diff)
81 self.assertEquals(p.is_new, is_new) 81 self.assertEquals(p.is_new, is_new)
82 if hasattr(p, 'patchlevel'): 82 if hasattr(p, 'patchlevel'):
83 self.assertEquals(p.patchlevel, patchlevel) 83 self.assertEquals(p.patchlevel, patchlevel)
84 if diff: 84 if diff:
85 self.assertEquals(p.get(), diff) 85 self.assertEquals(p.get(True), diff)
86 if hasattr(p, 'svn_properties'): 86 if hasattr(p, 'svn_properties'):
87 self.assertEquals(p.svn_properties, svn_properties) 87 self.assertEquals(p.svn_properties, svn_properties)
88 88
89 def test_get_patch_no_status(self): 89 def test_get_patch_no_status(self):
90 self.requests = [('/api/123/456', _api({'file_a': {}}))] 90 self.requests = [('/api/123/456', _api({'file_a': {}}))]
91 try: 91 try:
92 self.rietveld.get_patch(123, 456) 92 self.rietveld.get_patch(123, 456)
93 self.fail() 93 self.fail()
94 except patch.UnsupportedPatchFormat, e: 94 except patch.UnsupportedPatchFormat, e:
95 self.assertEquals('file_a', e.filename) 95 self.assertEquals('file_a', e.filename)
96 96
97 def test_get_patch_2_files(self): 97 def test_get_patch_2_files(self):
98 self.requests = [ 98 self.requests = [
99 ('/api/123/456', 99 ('/api/123/456',
100 _api({'foo': _file('A'), 'file_a': _file('M', chunk_id=790)})), 100 _api({'foo': _file('A'), 'file_a': _file('M', chunk_id=790)})),
101 ('/download/issue123_456_789.diff', RAW.NEW), 101 ('/download/issue123_456_789.diff', RAW.NEW),
102 ('/download/issue123_456_790.diff', RAW.NEW_NOT_NULL), 102 ('/download/issue123_456_790.diff', RAW.NEW_NOT_NULL),
103 ] 103 ]
104 patches = self.rietveld.get_patch(123, 456) 104 patches = self.rietveld.get_patch(123, 456)
105 self.assertEquals(2, len(patches.patches)) 105 self.assertEquals(2, len(patches.patches))
106 self._check_patch(patches.patches[0], 'foo', RAW.NEW, is_new=True)
107 # TODO(maruel): svn sucks. 106 # TODO(maruel): svn sucks.
108 self._check_patch(patches.patches[1], 'file_a', RAW.NEW_NOT_NULL) 107 self._check_patch(patches.patches[0], 'file_a', RAW.NEW_NOT_NULL)
108 self._check_patch(patches.patches[1], 'foo', RAW.NEW, is_new=True)
109 109
110 def test_get_patch_add(self): 110 def test_get_patch_add(self):
111 self.requests = [ 111 self.requests = [
112 ('/api/123/456', _api({'foo': _file('A')})), 112 ('/api/123/456', _api({'foo': _file('A')})),
113 ('/download/issue123_456_789.diff', RAW.NEW), 113 ('/download/issue123_456_789.diff', RAW.NEW),
114 ] 114 ]
115 patches = self.rietveld.get_patch(123, 456) 115 patches = self.rietveld.get_patch(123, 456)
116 self.assertEquals(1, len(patches.patches)) 116 self.assertEquals(1, len(patches.patches))
117 self._check_patch(patches.patches[0], 'foo', RAW.NEW, is_new=True) 117 self._check_patch(patches.patches[0], 'foo', RAW.NEW, is_new=True)
118 118
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 {'foo': 'prout'}, 342 {'foo': 'prout'},
343 ] 343 ]
344 for i in self.rietveld.search(base='base'): 344 for i in self.rietveld.search(base='base'):
345 self.assertEquals(expected.pop(0), i) 345 self.assertEquals(expected.pop(0), i)
346 self.assertEquals([], expected) 346 self.assertEquals([], expected)
347 347
348 348
349 if __name__ == '__main__': 349 if __name__ == '__main__':
350 logging.basicConfig(level=logging.ERROR) 350 logging.basicConfig(level=logging.ERROR)
351 unittest.main() 351 unittest.main()
OLDNEW
« no previous file with comments | « tests/patch_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698