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

Side by Side Diff: tests/rietveld_test.py

Issue 14061008: Have Rietveld.get_description() consistently strip CR and whitespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 7 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
« rietveld.py ('K') | « 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) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 def test_get_description(self): 397 def test_get_description(self):
398 self.requests = [ 398 self.requests = [
399 ('/1/description', 'Blah blah blah'), 399 ('/1/description', 'Blah blah blah'),
400 ] 400 ]
401 expected = 'Blah blah blah' 401 expected = 'Blah blah blah'
402 self.assertEqual(expected, self.rietveld.get_description(1)) 402 self.assertEqual(expected, self.rietveld.get_description(1))
403 self.assertEqual(expected, self.rietveld.get_description(1)) 403 self.assertEqual(expected, self.rietveld.get_description(1))
404 404
405 def test_get_issue_properties(self): 405 def test_get_issue_properties(self):
406 data = {'description': 'wow\r\nno CR!', 'messages': 'foo'}
406 self.requests = [ 407 self.requests = [
407 ('/api/1?messages=true', rietveld.json.dumps({'messages': 'foo'})), 408 ('/api/1?messages=true', rietveld.json.dumps(data)),
408 ] 409 ]
409 expected = {} 410 expected = {u'description': u'wow\nno CR!'}
410 expected_msg = {'messages': 'foo'} 411 expected_msg = {u'description': u'wow\nno CR!', u'messages': u'foo'}
411 self.assertEqual(expected, self.rietveld.get_issue_properties(1, False)) 412 self.assertEqual(expected, self.rietveld.get_issue_properties(1, False))
412 self.assertEqual(expected_msg, self.rietveld.get_issue_properties(1, True)) 413 self.assertEqual(expected_msg, self.rietveld.get_issue_properties(1, True))
413 414
414 def test_get_patchset_properties(self): 415 def test_get_patchset_properties(self):
415 self.requests = [ 416 self.requests = [
416 ('/api/1/2', '{}'), 417 ('/api/1/2', '{}'),
417 ] 418 ]
418 expected = {} 419 expected = {}
419 self.assertEqual(expected, self.rietveld.get_patchset_properties(1, 2)) 420 self.assertEqual(expected, self.rietveld.get_patchset_properties(1, 2))
420 self.assertEqual(expected, self.rietveld.get_patchset_properties(1, 2)) 421 self.assertEqual(expected, self.rietveld.get_patchset_properties(1, 2))
421 422
422 423
423 424
424 if __name__ == '__main__': 425 if __name__ == '__main__':
425 logging.basicConfig(level=[ 426 logging.basicConfig(level=[
426 logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))]) 427 logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))])
427 unittest.main() 428 unittest.main()
OLDNEW
« rietveld.py ('K') | « rietveld.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698