From: Kevin McCarthy Date: Sat, 30 Jun 2012 22:54:00 +0000 (-1000) Subject: add tests for multiple requests X-Git-Tag: v0.1.0~92 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=66e7ce9572a222ef14158f24bd500ece0c0f58b3;p=vcrpy.git add tests for multiple requests --- diff --git a/test.py b/test.py index abfd33a..1379fa9 100644 --- a/test.py +++ b/test.py @@ -31,6 +31,15 @@ class TestHttpRequest(unittest.TestCase): headers = urllib2.urlopen('http://www.iana.org/domains/example/').info().items() self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info().items()) + def test_multiple_requests(self): + body1 = urllib2.urlopen('http://www.iana.org/domains/example/').read() + body2 = urllib2.urlopen('http://api.twitter.com/1/legal/tos.json').read() + with vcr.use_cassette(TEST_CASSETTE_FILE): + self.assertEqual(body1, urllib2.urlopen('http://www.iana.org/domains/example/').read()) + self.assertEqual(body2, urllib2.urlopen('http://api.twitter.com/1/legal/tos.json').read()) + self.assertEqual(body1, urllib2.urlopen('http://www.iana.org/domains/example/').read()) + self.assertEqual(body2, urllib2.urlopen('http://api.twitter.com/1/legal/tos.json').read()) + class TestHttps(unittest.TestCase): @@ -47,7 +56,7 @@ class TestHttps(unittest.TestCase): self.assertEqual(code, urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').getcode()) def test_response_body(self): - body = urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').read() + body = urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').read() with vcr.use_cassette(TEST_CASSETTE_FILE): self.assertEqual(body, urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').read()) self.assertEqual(body, urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').read())