mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Added 'scheme' to Request with matcher and test
This commit is contained in:
@@ -8,7 +8,7 @@ from vcr import request
|
|||||||
REQUESTS = {
|
REQUESTS = {
|
||||||
'base': request.Request('GET', 'http://host.com:80/p?a=b', '', {}),
|
'base': request.Request('GET', 'http://host.com:80/p?a=b', '', {}),
|
||||||
'method': request.Request('POST', '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', '', {}),
|
'host': request.Request('GET', 'http://another-host.com:80/p?a=b', '', {}),
|
||||||
'port': request.Request('GET', 'http://host.com:90/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', '', {}),
|
'path': request.Request('GET', 'http://host.com:80/x?a=b', '', {}),
|
||||||
@@ -49,6 +49,7 @@ def test_query_matcher():
|
|||||||
|
|
||||||
def test_metchers():
|
def test_metchers():
|
||||||
assert_matcher('method')
|
assert_matcher('method')
|
||||||
|
assert_matcher('scheme')
|
||||||
assert_matcher('host')
|
assert_matcher('host')
|
||||||
assert_matcher('port')
|
assert_matcher('port')
|
||||||
assert_matcher('path')
|
assert_matcher('path')
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ def host(r1, r2):
|
|||||||
return r1.host == r2.host
|
return r1.host == r2.host
|
||||||
|
|
||||||
|
|
||||||
|
def scheme(r1, r2):
|
||||||
|
return r1.scheme == r2.scheme
|
||||||
|
|
||||||
|
|
||||||
def port(r1, r2):
|
def port(r1, r2):
|
||||||
return r1.port == r2.port
|
return r1.port == r2.port
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ class Request(object):
|
|||||||
tmp[key] = value
|
tmp[key] = value
|
||||||
self.headers = frozenset(tmp.iteritems())
|
self.headers = frozenset(tmp.iteritems())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def scheme(self):
|
||||||
|
return urlparse(self.uri).scheme
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
return urlparse(self.uri).hostname
|
return urlparse(self.uri).hostname
|
||||||
|
|||||||
Reference in New Issue
Block a user