]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Added test to confirm whether cStringIO works
authorshu zOMG chen <shu.chen@freelancedreams.com>
Wed, 21 Aug 2013 20:44:30 +0000 (10:44 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Fri, 23 Aug 2013 03:31:57 +0000 (17:31 -1000)
tests/integration/test_basic.py

index 9ddb669f13f43f2e342fb0b928a627d85a59f521..250eea68d3aba62d307aef15148776eb635f96e9 100644 (file)
@@ -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