예제 #1
0
 def test_proxy_from_env_https_without_port_without_method(self):
     with mock.patch.dict(os.environ, https_proxy='localhost'):
         proxy_info = proxy_info_from_environment_var('https_proxy')
         expected = ProxyInfo(3, 'localhost', 443)
         self.assertEqual(str(expected), str(proxy_info))
예제 #2
0
 def test_proxy_from_env_invalid_var(self):
     proxy_info = proxy_info_from_environment_var('http_proxy_host')
     expected = None
     self.assertEqual(str(expected), str(proxy_info))
예제 #3
0
 def test_proxy_from_env_wrong_method_in_url(self):
   os.environ['http_proxy'] = 'smtp://localhost:8000'
   proxy_info = proxy_info_from_environment_var('http_proxy')
   expected = ProxyInfo(3, 'smtp', 80) # wrong proxy info generated
   self.assertEquals(str(expected), str(proxy_info))
예제 #4
0
 def test_proxy_from_env_https_with_port(self):
     with mock.patch.dict(os.environ, https_proxy='https://localhost:9000'):
         proxy_info = proxy_info_from_environment_var('https_proxy')
         expected = ProxyInfo(3, 'localhost', 9000)
         self.assertEqual(str(expected), str(proxy_info))
예제 #5
0
 def test_proxy_from_env_invalid_var(self):
   proxy_info = proxy_info_from_environment_var('http_proxy_host')
   expected = None
   self.assertEquals(str(expected), str(proxy_info))
예제 #6
0
 def test_proxy_from_env_wrong_method_in_var_name(self):
   os.environ['smtp_proxy'] = 'localhost'
   with self.assertRaises(KeyError):
     proxy_info_from_environment_var('smtp_proxy')
예제 #7
0
 def test_proxy_from_env_https_with_port(self):
   os.environ['https_proxy'] = 'https://localhost:9000'
   proxy_info = proxy_info_from_environment_var('https_proxy')
   expected = ProxyInfo(3, 'localhost', 9000)
   self.assertEquals(str(expected), str(proxy_info))
예제 #8
0
 def test_proxy_from_env_https_without_port_without_method(self):
     os.environ['https_proxy'] = 'localhost'
     proxy_info = proxy_info_from_environment_var('https_proxy')
     expected = ProxyInfo(3, 'localhost', 443)
     self.assertEquals(str(expected), str(proxy_info))
예제 #9
0
 def test_proxy_from_env_https_without_port_without_method(self):
   with mock.patch.dict(os.environ, https_proxy='localhost'):
     proxy_info = proxy_info_from_environment_var('https_proxy')
     expected = ProxyInfo(3, 'localhost', 443)
     self.assertEquals(str(expected), str(proxy_info))
예제 #10
0
 def test_proxy_from_env_wrong_method_in_var_name(self):
   with mock.patch.dict(os.environ, smtp_proxy='localhost'):
     with self.assertRaises(KeyError):
       proxy_info_from_environment_var('smtp_proxy')
예제 #11
0
 def test_proxy_from_env_https_with_port(self):
   with mock.patch.dict(os.environ, https_proxy='https://localhost:9000'):
     proxy_info = proxy_info_from_environment_var('https_proxy')
     expected = ProxyInfo(3, 'localhost', 9000)
     self.assertEquals(str(expected), str(proxy_info))
예제 #12
0
 def test_proxy_from_env_wrong_method_in_url(self):
     os.environ['http_proxy'] = 'smtp://localhost:8000'
     proxy_info = proxy_info_from_environment_var('http_proxy')
     expected = ProxyInfo(3, 'smtp', 80)  # wrong proxy info generated
     self.assertEquals(str(expected), str(proxy_info))
예제 #13
0
 def test_proxy_from_env_wrong_method_in_var_name(self):
     os.environ['smtp_proxy'] = 'localhost'
     with self.assertRaises(KeyError):
         proxy_info_from_environment_var('smtp_proxy')
예제 #14
0
 def test_proxy_from_env_wrong_method_in_var_name(self):
     with mock.patch.dict(os.environ, smtp_proxy='localhost'):
         with self.assertRaises(KeyError):
             proxy_info_from_environment_var('smtp_proxy')
예제 #15
0
 def test_proxy_from_env_https_without_port_without_method(self):
   os.environ['https_proxy'] = 'localhost'
   proxy_info = proxy_info_from_environment_var('https_proxy')
   expected = ProxyInfo(3, 'localhost', 443)
   self.assertEquals(str(expected), str(proxy_info))
예제 #16
0
 def test_proxy_from_env_wrong_method_in_url(self):
     with mock.patch.dict(os.environ, http_proxy='smtp://localhost:8000'):
         proxy_info = proxy_info_from_environment_var('http_proxy')
         expected = ProxyInfo(3, 'smtp', 80)  # wrong proxy info generated
         self.assertEqual(str(expected), str(proxy_info))
예제 #17
0
 def test_proxy_from_env_https_with_port(self):
     os.environ['https_proxy'] = 'https://localhost:9000'
     proxy_info = proxy_info_from_environment_var('https_proxy')
     expected = ProxyInfo(3, 'localhost', 9000)
     self.assertEquals(str(expected), str(proxy_info))