From: Max Shytikov Date: Sun, 6 Apr 2014 23:56:55 +0000 (+0200) Subject: Added 'scheme' to Request with matcher and test X-Git-Tag: v1.0.0~36^2~44 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=4267828a3e45751902ee9ef3ba9cfd971ea15223;p=vcrpy.git Added 'scheme' to Request with matcher and test --- diff --git a/tests/unit/test_matchers.py b/tests/unit/test_matchers.py index e3c85fb..30ab5ff 100644 --- a/tests/unit/test_matchers.py +++ b/tests/unit/test_matchers.py @@ -8,7 +8,7 @@ from vcr import request REQUESTS = { 'base': request.Request('GET', 'http://host.com:80/p?a=b', '', {}), 'method': request.Request('POST', 'http://host.com:80/p?a=b', '', {}), - 'protocol': request.Request('GET', 'https://host.com:80/p?a=b', '', {}), + 'scheme': request.Request('GET', 'https://host.com:80/p?a=b', '', {}), 'host': request.Request('GET', 'http://another-host.com:80/p?a=b', '', {}), 'port': request.Request('GET', 'http://host.com:90/p?a=b', '', {}), 'path': request.Request('GET', 'http://host.com:80/x?a=b', '', {}), @@ -49,6 +49,7 @@ def test_query_matcher(): def test_metchers(): assert_matcher('method') + assert_matcher('scheme') assert_matcher('host') assert_matcher('port') assert_matcher('path') diff --git a/vcr/matchers.py b/vcr/matchers.py index 4dde6a0..1918652 100644 --- a/vcr/matchers.py +++ b/vcr/matchers.py @@ -13,6 +13,10 @@ def host(r1, r2): return r1.host == r2.host +def scheme(r1, r2): + return r1.scheme == r2.scheme + + def port(r1, r2): return r1.port == r2.port diff --git a/vcr/request.py b/vcr/request.py index ca6faee..9e76352 100644 --- a/vcr/request.py +++ b/vcr/request.py @@ -15,6 +15,10 @@ class Request(object): tmp[key] = value self.headers = frozenset(tmp.iteritems()) + @property + def scheme(self): + return urlparse(self.uri).scheme + @property def host(self): return urlparse(self.uri).hostname