示例#1
0
文件: test_api.py 项目: SeyfSV/pypac
 def test_download_pac_content_type(self, headers, allowed_content_types,
                                    expected_value):
     """Test acceptance/rejection of obtained PAC based on Content-Type header."""
     mock_pac_response = Mock(spec=requests.Response,
                              ok=True,
                              headers=headers,
                              text=direct_pac_js)
     with _patch_request_base(mock_pac_response):
         result = download_pac([arbitrary_pac_url],
                               allowed_content_types=allowed_content_types)
         assert result == expected_value
示例#2
0
文件: test_api.py 项目: SeyfSV/pypac
 def test_download_pac_not_ok(self):
     mock_resp_not_ok = Mock(ok=False,
                             headers=valid_pac_headers,
                             text=direct_pac_js)
     with _patch_request_base(mock_resp_not_ok):
         assert download_pac([arbitrary_pac_url]) is None
示例#3
0
文件: test_api.py 项目: SeyfSV/pypac
 def test_download_pac_timeout(self):
     assert download_pac([arbitrary_pac_url], timeout=0.001) is None
示例#4
0
 def test_download_pac_content_type(self, headers, allowed_content_types, expected_value):
     """Test acceptance/rejection of obtained PAC based on Content-Type header."""
     mock_pac_response = Mock(spec=requests.Response, ok=True, headers=headers, text=direct_pac_js)
     with _patch_request_base(mock_pac_response):
         result = download_pac([arbitrary_pac_url], allowed_content_types=allowed_content_types)
         assert result == expected_value
示例#5
0
 def test_download_pac_not_ok(self):
     mock_resp_not_ok = Mock(ok=False, headers=valid_pac_headers, text=direct_pac_js)
     with _patch_request_base(mock_resp_not_ok):
         assert download_pac([arbitrary_pac_url]) is None
示例#6
0
 def test_download_pac_timeout(self):
     assert download_pac([arbitrary_pac_url], timeout=0.001) is None