1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-10 01:25:34 +00:00

meh I guess HTTPS works

This commit is contained in:
Kevin McCarthy
2012-06-29 21:52:24 -10:00
parent 602e0b2aa8
commit 44af536510
2 changed files with 30 additions and 5 deletions

32
test.py
View File

@@ -8,7 +8,7 @@ TEST_CASSETTE_FILE = 'test/test_req.yaml'
class TestHttpRequest(unittest.TestCase):
def setUp(self):
def tearDown(self):
try:
os.remove(TEST_CASSETTE_FILE)
except OSError:
@@ -22,15 +22,41 @@ class TestHttpRequest(unittest.TestCase):
def test_response_body(self):
body = urllib2.urlopen('http://www.iana.org/domains/example/').read()
with vcr.use_cassette('test/synopsis.yaml'):
with vcr.use_cassette(TEST_CASSETTE_FILE):
self.assertEqual(body, urllib2.urlopen('http://www.iana.org/domains/example/').read())
self.assertEqual(body, urllib2.urlopen('http://www.iana.org/domains/example/').read())
def test_response_headers(self):
with vcr.use_cassette('test/synopsis.yaml'):
with vcr.use_cassette(TEST_CASSETTE_FILE):
headers = urllib2.urlopen('http://www.iana.org/domains/example/').info().items()
self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info().items())
class TestHttps(unittest.TestCase):
def tearDown(self):
try:
os.remove(TEST_CASSETTE_FILE)
except OSError:
pass
def test_response_code(self):
code = urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').getcode()
with vcr.use_cassette(TEST_CASSETTE_FILE):
self.assertEqual(code, urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').getcode())
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()
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())
def test_response_headers(self):
with vcr.use_cassette(TEST_CASSETTE_FILE):
headers = urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').info().items()
self.assertEqual(headers, urllib2.urlopen('https://api.twitter.com/1/legal/tos.json').info().items())
if __name__ == '__main__':
unittest.main()