From 08d4d8913ae80a31e927b3e243ad4dd057bb3b58 Mon Sep 17 00:00:00 2001 From: Max Shytikov Date: Tue, 1 Apr 2014 22:44:03 +0200 Subject: [PATCH] Added integration test for match on 'method' --- tests/integration/test_matchers.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/integration/test_matchers.py diff --git a/tests/integration/test_matchers.py b/tests/integration/test_matchers.py new file mode 100644 index 0000000..1b7765d --- /dev/null +++ b/tests/integration/test_matchers.py @@ -0,0 +1,24 @@ +import vcr +import pytest +from six.moves.urllib.request import urlopen + + +@pytest.fixture +def cassette(tmpdir): + return str(tmpdir.join('test.yml')) + + +def test_method_matcher(cassette): + # prepare cassete + with vcr.use_cassette(cassette, match_on=['method']) as cass: + urlopen('http://httpbin.org/') + assert len(cass) == 1 + + # play cassette with matching on method + with vcr.use_cassette(cassette, match_on=['method']) as cass: + urlopen('http://httpbin.org/get') + assert cass.play_count == 1 + + with pytest.raises(vcr.errors.CannotOverwriteExistingCassetteException): + with vcr.use_cassette(cassette, match_on=['method']) as cass: + urlopen('http://httpbin.org/post', data='')