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

Side by Side Diff: tests/rietveld_test.py

Issue 1075723002: Extract authentication options handling into a separate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « tests/presubmit_unittest.py ('k') | third_party/upload.py » ('j') | 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 ssl 10 import ssl
(...skipping 29 matching lines...) Expand all
40 40
41 41
42 class BaseFixture(unittest.TestCase): 42 class BaseFixture(unittest.TestCase):
43 # Override. 43 # Override.
44 TESTED_CLASS = Exception 44 TESTED_CLASS = Exception
45 45
46 def setUp(self): 46 def setUp(self):
47 super(BaseFixture, self).setUp() 47 super(BaseFixture, self).setUp()
48 # Access to a protected member XX of a client class 48 # Access to a protected member XX of a client class
49 # pylint: disable=W0212 49 # pylint: disable=W0212
50 self.rietveld = self.TESTED_CLASS('url', 'email', 'password') 50 self.rietveld = self.TESTED_CLASS('url', None, 'email')
51 self.rietveld._send = self._rietveld_send 51 self.rietveld._send = self._rietveld_send
52 self.requests = [] 52 self.requests = []
53 53
54 def tearDown(self): 54 def tearDown(self):
55 self.assertEqual([], self.requests) 55 self.assertEqual([], self.requests)
56 super(BaseFixture, self).tearDown() 56 super(BaseFixture, self).tearDown()
57 57
58 def _rietveld_send(self, url, *args, **kwargs): 58 def _rietveld_send(self, url, *args, **kwargs):
59 self.assertTrue(self.requests, url) 59 self.assertTrue(self.requests, url)
60 request = self.requests.pop(0) 60 request = self.requests.pop(0)
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 **kwargs): 449 **kwargs):
450 """Mock upload.py's Send() to raise SSLError""" 450 """Mock upload.py's Send() to raise SSLError"""
451 raise ssl.SSLError('The read operation timed out') 451 raise ssl.SSLError('The read operation timed out')
452 452
453 453
454 class DefaultTimeoutTest(auto_stub.TestCase): 454 class DefaultTimeoutTest(auto_stub.TestCase):
455 TESTED_CLASS = rietveld.Rietveld 455 TESTED_CLASS = rietveld.Rietveld
456 456
457 def setUp(self): 457 def setUp(self):
458 super(DefaultTimeoutTest, self).setUp() 458 super(DefaultTimeoutTest, self).setUp()
459 self.rietveld = self.TESTED_CLASS('url', 'email', 'password') 459 self.rietveld = self.TESTED_CLASS('url', None, 'email')
460 self.mock(self.rietveld.rpc_server, 'Send', MockSend) 460 self.mock(self.rietveld.rpc_server, 'Send', MockSend)
461 self.sleep_time = 0 461 self.sleep_time = 0
462 462
463 def test_timeout_get(self): 463 def test_timeout_get(self):
464 with self.assertRaises(ProbeException) as cm: 464 with self.assertRaises(ProbeException) as cm:
465 self.rietveld.get('/api/1234') 465 self.rietveld.get('/api/1234')
466 466
467 self.assertIsNotNone(cm.exception.value, 'Rietveld timeout was not set: %s' 467 self.assertIsNotNone(cm.exception.value, 'Rietveld timeout was not set: %s'
468 % traceback.format_exc()) 468 % traceback.format_exc())
469 469
(...skipping 12 matching lines...) Expand all
482 self.mock(time, 'sleep', self.MockSleep) 482 self.mock(time, 'sleep', self.MockSleep)
483 self.sleep_time = 0 483 self.sleep_time = 0
484 with self.assertRaises(ssl.SSLError): 484 with self.assertRaises(ssl.SSLError):
485 self.rietveld.post('/api/1234', [('key', 'data')]) 485 self.rietveld.post('/api/1234', [('key', 'data')])
486 self.assertNotEqual(self.sleep_time, 0) 486 self.assertNotEqual(self.sleep_time, 0)
487 487
488 if __name__ == '__main__': 488 if __name__ == '__main__':
489 logging.basicConfig(level=[ 489 logging.basicConfig(level=[
490 logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))]) 490 logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))])
491 unittest.main() 491 unittest.main()
OLDNEW
« no previous file with comments | « tests/presubmit_unittest.py ('k') | third_party/upload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698