From c5eca93edc34815f799d9c486a91ce0a61674589 Mon Sep 17 00:00:00 2001 From: shu zOMG chen Date: Wed, 21 Aug 2013 10:44:30 -1000 Subject: [PATCH] Added test to confirm whether cStringIO works --- tests/integration/test_basic.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/integration/test_basic.py b/tests/integration/test_basic.py index 9ddb669..250eea6 100644 --- a/tests/integration/test_basic.py +++ b/tests/integration/test_basic.py @@ -43,3 +43,37 @@ def test_basic_json_use(tmpdir): with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.json', serializer='json'): response = urllib2.urlopen('http://www.iana.org/domains/reserved').read() assert 'Example domains' in response + +def test_patched_content(tmpdir): + '''Ensure that what you pull from a cassette is what came from the request''' + with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass: + response = urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 0 + + with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass: + response2= urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 1 + + with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass: + response3= urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 1 + + assert response == response2 + assert response2 == response3 + +def test_patched_content_json(tmpdir): + '''Ensure that what you pull from a json cassette is what came from the request''' + with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass: + response = urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 0 + + with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass: + response2= urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 1 + + with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass: + response3= urllib2.urlopen('http://www.iana.org/domains/reserved').read() + assert cass.play_count == 1 + + assert response == response2 + assert response2 == response3