From 0be7d6f23807b2ad6d0166250a53f216c8e4f498 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 3 May 2014 15:52:45 -1000 Subject: [PATCH] oops, forgot to commit new tests for ignore feature --- tests/integration/test_ignore.py | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/integration/test_ignore.py diff --git a/tests/integration/test_ignore.py b/tests/integration/test_ignore.py new file mode 100644 index 0000000..69ed1d9 --- /dev/null +++ b/tests/integration/test_ignore.py @@ -0,0 +1,41 @@ +import base64 +import pytest +from six.moves.urllib.request import urlopen, Request +from six.moves.urllib.error import HTTPError +import vcr + + +def test_ignore_localhost(tmpdir, httpserver): + httpserver.serve_content('Hello!') + cass_file = str(tmpdir.join('filter_qs.yaml')) + with vcr.use_cassette(cass_file, ignore_localhost=True) as cass: + urlopen(httpserver.url) + assert len(cass) == 0 + urlopen('http://httpbin.org') + assert len(cass) == 1 + + +def test_ignore_httpbin(tmpdir, httpserver): + httpserver.serve_content('Hello!') + cass_file = str(tmpdir.join('filter_qs.yaml')) + with vcr.use_cassette( + cass_file, + ignore_hosts=['httpbin.org'] + ) as cass: + urlopen('http://httpbin.org') + assert len(cass) == 0 + urlopen(httpserver.url) + assert len(cass) == 1 + + +def test_ignore_localhost_and_httpbin(tmpdir, httpserver): + httpserver.serve_content('Hello!') + cass_file = str(tmpdir.join('filter_qs.yaml')) + with vcr.use_cassette( + cass_file, + ignore_hosts=['httpbin.org'], + ignore_localhost=True + ) as cass: + urlopen('http://httpbin.org') + urlopen(httpserver.url) + assert len(cass) == 0