示例#1
0
文件: tests.py 项目: storecast/holon
 def test_call_helper_exception(self, transport):
     getresponse_mock = Mock()
     getresponse_mock.getresponse = Mock(side_effect=HTTPException)
     transport.return_value = getresponse_mock
     s = HttpLibHttpService('host', 42, 'path')
     with self.assertRaises(s.communication_error_class):
         s._call('body', {})
示例#2
0
文件: tests.py 项目: storecast/holon
 def test_call_helper(self, transport):
     getresponse_mock = Mock()
     transport.return_value = getresponse_mock
     read_mock = Mock()
     read_mock.read = Mock(return_value='data!')
     getresponse_mock.getresponse = Mock(return_value=read_mock)
     s = HttpLibHttpService('host', 42, 'path')
     r = s._call('body', {})
     self.assertIsInstance(r, tuple)
     self.assertEqual(len(r), 3)
示例#3
0
文件: tests.py 项目: storecast/holon
 def test_protocol_https(self):
     s = HttpLibHttpService('host', 443, 'path')
     self.assertEqual(s.protocol, HTTPSConnection._http_vsn_str)
     self.assertIsInstance(s.get_transport(), HTTPSConnection)