Here are the examples of the python api requests.get.AndReturn taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
Project: heat Source File: test_urlfetch.py
def test_http_scheme(self):
url = 'http://example.com/template'
data = b'{ "foo": "bar" }'
response = Response(data)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
self.assertEqual(data, urlfetch.get(url))
self.m.VerifyAll()
3
Example 2
Project: heat Source File: test_urlfetch.py
def test_https_scheme(self):
url = 'https://example.com/template'
data = b'{ "foo": "bar" }'
response = Response(data)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
self.assertEqual(data, urlfetch.get(url))
self.m.VerifyAll()
3
Example 3
Project: heat Source File: test_urlfetch.py
def test_max_fetch_size_okay(self):
url = 'http://example.com/template'
data = b'{ "foo": "bar" }'
response = Response(data)
cfg.CONF.set_override('max_template_size', 500, enforce_type=True)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
urlfetch.get(url)
self.m.VerifyAll()
3
Example 4
Project: heat Source File: test_urlfetch.py
def test_max_fetch_size_error(self):
url = 'http://example.com/template'
data = b'{ "foo": "bar" }'
response = Response(data)
cfg.CONF.set_override('max_template_size', 5, enforce_type=True)
requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll()
exception = self.assertRaises(urlfetch.URLFetchError,
urlfetch.get, url)
self.assertIn("Template exceeds", six.text_type(exception))
self.m.VerifyAll()