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

Unified Diff: tests/rietveld_test.py

Issue 180723002: Incorrect SSLError attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « rietveld.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/rietveld_test.py
diff --git a/tests/rietveld_test.py b/tests/rietveld_test.py
index 3ac2444881686ae66d864d5947c9a81780b9b130..20edb5056fb293662076cd42ee42a04ce89e4cc5 100755
--- a/tests/rietveld_test.py
+++ b/tests/rietveld_test.py
@@ -7,7 +7,9 @@
import logging
import os
+import ssl
import sys
+import time
import traceback
import unittest
@@ -440,6 +442,14 @@ def MockSend(request_path, payload=None,
"""Mock upload.py's Send() to probe the timeout value"""
raise ProbeException(timeout)
+def MockSendTimeout(request_path, payload=None,
+ content_type="application/octet-stream",
+ timeout=None,
+ extra_headers=None,
+ **kwargs):
+ """Mock upload.py's Send() to raise SSLError"""
+ raise ssl.SSLError('The read operation timed out')
+
class DefaultTimeoutTest(auto_stub.TestCase):
TESTED_CLASS = rietveld.Rietveld
@@ -448,6 +458,7 @@ class DefaultTimeoutTest(auto_stub.TestCase):
super(DefaultTimeoutTest, self).setUp()
self.rietveld = self.TESTED_CLASS('url', 'email', 'password')
self.mock(self.rietveld.rpc_server, 'Send', MockSend)
+ self.sleep_time = 0
def test_timeout_get(self):
with self.assertRaises(ProbeException) as cm:
@@ -463,6 +474,16 @@ class DefaultTimeoutTest(auto_stub.TestCase):
self.assertIsNotNone(cm.exception.value, 'Rietveld timeout was not set: %s'
% traceback.format_exc())
+ def MockSleep(self, t):
+ self.sleep_time = t
+
+ def test_ssl_timeout_post(self):
+ self.mock(self.rietveld.rpc_server, 'Send', MockSendTimeout)
+ self.mock(time, 'sleep', self.MockSleep)
+ self.sleep_time = 0
+ with self.assertRaises(ssl.SSLError):
+ self.rietveld.post('/api/1234', [('key', 'data')])
+ self.assertNotEqual(self.sleep_time, 0)
if __name__ == '__main__':
logging.basicConfig(level=[
« 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