OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 import json | 6 import json |
7 import mock | 7 import mock |
8 import os | 8 import os |
9 import urllib | 9 import urllib |
10 import zlib | 10 import zlib |
11 | 11 |
12 from google.appengine.api.urlfetch_errors import DeadlineExceededError | 12 from google.appengine.api.urlfetch_errors import DeadlineExceededError |
13 from google.appengine.api.urlfetch_errors import DownloadError | 13 from google.appengine.api.urlfetch_errors import DownloadError |
14 from google.appengine.api.urlfetch_errors import ConnectionClosedError | 14 from google.appengine.api.urlfetch_errors import ConnectionClosedError |
15 | 15 |
16 from common.http_client_appengine import HttpClientAppengine as HttpClient | 16 from common.http_client_appengine import HttpClientAppengine as HttpClient |
17 from common.retry_http_client import RetryHttpClient | 17 from libs.http.retry_http_client import RetryHttpClient |
18 from model.wf_config import FinditConfig | 18 from model.wf_config import FinditConfig |
19 from model.wf_step import WfStep | 19 from model.wf_step import WfStep |
20 from waterfall import swarming_util | 20 from waterfall import swarming_util |
21 from waterfall import waterfall_config | 21 from waterfall import waterfall_config |
22 from waterfall.swarming_task_request import SwarmingTaskRequest | 22 from waterfall.swarming_task_request import SwarmingTaskRequest |
23 from waterfall.test import wf_testcase | 23 from waterfall.test import wf_testcase |
24 | 24 |
25 | 25 |
26 class SwarmingHttpClient(RetryHttpClient): | 26 class SwarmingHttpClient(RetryHttpClient): |
27 | 27 |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 content, error = swarming_util._SendRequestToServer('url', HttpClient()) | 635 content, error = swarming_util._SendRequestToServer('url', HttpClient()) |
636 self.assertIsNone(content) | 636 self.assertIsNone(content) |
637 self.assertEqual( | 637 self.assertEqual( |
638 error['code'], swarming_util.URLFETCH_DEADLINE_EXCEEDED_ERROR) | 638 error['code'], swarming_util.URLFETCH_DEADLINE_EXCEEDED_ERROR) |
639 | 639 |
640 @mock.patch.object(RetryHttpClient, 'Get', side_effect=DownloadError()) | 640 @mock.patch.object(RetryHttpClient, 'Get', side_effect=DownloadError()) |
641 def testSendRequestToServerDownloadError(self, _): | 641 def testSendRequestToServerDownloadError(self, _): |
642 content, error = swarming_util._SendRequestToServer('url', HttpClient()) | 642 content, error = swarming_util._SendRequestToServer('url', HttpClient()) |
643 self.assertIsNone(content) | 643 self.assertIsNone(content) |
644 self.assertEqual(error['code'], swarming_util.URLFETCH_DOWNLOAD_ERROR) | 644 self.assertEqual(error['code'], swarming_util.URLFETCH_DOWNLOAD_ERROR) |
OLD | NEW |