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

Side by Side Diff: tests/rietveld_test.py

Issue 7754016: Fix rietveld when status is only one char (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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 | « rietveld.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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) 106 self._check_patch(patches.patches[0], 'foo', RAW.NEW, is_new=True)
107 # TODO(maruel): svn sucks. 107 # TODO(maruel): svn sucks.
108 self._check_patch(patches.patches[1], 'file_a', RAW.NEW_NOT_NULL) 108 self._check_patch(patches.patches[1], 'file_a', RAW.NEW_NOT_NULL)
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
119 def test_invalid_status(self): 119 def test_invalid_status(self):
120 self.requests = [ 120 self.requests = [
121 ('/api/123/456', _api({'file_a': _file('B')})), 121 ('/api/123/456', _api({'file_a': _file('B')})),
122 ] 122 ]
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 self.fail() 263 self.fail()
264 except rietveld.patch.UnsupportedPatchFormat, e: 264 except rietveld.patch.UnsupportedPatchFormat, e:
265 self.assertEquals('foo', e.filename) 265 self.assertEquals('foo', e.filename)
266 # TODO(maruel): Change with no diff, only svn property change: 266 # TODO(maruel): Change with no diff, only svn property change:
267 # http://codereview.chromium.org/6462019/ 267 # http://codereview.chromium.org/6462019/
268 268
269 269
270 if __name__ == '__main__': 270 if __name__ == '__main__':
271 logging.basicConfig(level=logging.ERROR) 271 logging.basicConfig(level=logging.ERROR)
272 unittest.main() 272 unittest.main()
OLDNEW
« no previous file with comments | « rietveld.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698