mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 09:35:34 +00:00
Replaced Request 'host, port, protocol, path' with 'uri'
This commit is contained in:
10
tests/fixtures/wild/domain_redirect.yaml
vendored
10
tests/fixtures/wild/domain_redirect.yaml
vendored
@@ -4,11 +4,8 @@
|
||||
- - !!python/tuple [Accept-Encoding, 'gzip, deflate, compress']
|
||||
- !!python/tuple [User-Agent, vcrpy-test]
|
||||
- !!python/tuple [Accept, '*/*']
|
||||
host: seomoz.org
|
||||
method: GET
|
||||
path: /
|
||||
port: 80
|
||||
protocol: http
|
||||
uri: http://seomoz.org:80/
|
||||
response:
|
||||
body: {string: ''}
|
||||
headers: ["Location: http://moz.com/\r\n", "Server: BigIP\r\n", "Connection: Keep-Alive\r\n",
|
||||
@@ -20,11 +17,8 @@
|
||||
- - !!python/tuple [Accept-Encoding, 'gzip, deflate, compress']
|
||||
- !!python/tuple [User-Agent, vcrpy-test]
|
||||
- !!python/tuple [Accept, '*/*']
|
||||
host: moz.com
|
||||
method: GET
|
||||
path: /
|
||||
port: 80
|
||||
protocol: http
|
||||
uri: http://moz.com:80/
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
|
||||
@@ -6,6 +6,6 @@ def test_recorded_request_url_with_redirected_request(tmpdir):
|
||||
with vcr.use_cassette(str(tmpdir.join('test.yml'))) as cass:
|
||||
assert len(cass) == 0
|
||||
urlopen('http://httpbin.org/redirect/3')
|
||||
assert cass.requests[0].url == 'http://httpbin.org/redirect/3'
|
||||
assert cass.requests[3].url == 'http://httpbin.org/get'
|
||||
assert cass.requests[0].url == 'http://httpbin.org:80/redirect/3'
|
||||
assert cass.requests[3].url == 'http://httpbin.org:80/get'
|
||||
assert len(cass) == 4
|
||||
|
||||
@@ -3,28 +3,28 @@ from vcr import request
|
||||
|
||||
|
||||
def test_method():
|
||||
req_get = request.Request('http', 'google.com', 80, 'GET', '/', '', {})
|
||||
req_get = request.Request('GET', 'http://google.com:80/', '', {})
|
||||
assert True == matchers.method(req_get, req_get)
|
||||
|
||||
req_get1 = request.Request('https', 'httpbin.org', 80, 'GET', '/', '', {})
|
||||
req_get1 = request.Request('GET', 'https://httpbin.org:80/', '', {})
|
||||
assert True == matchers.method(req_get, req_get1)
|
||||
|
||||
req_post = request.Request('http', 'google.com', 80, 'POST', '/', '', {})
|
||||
req_post = request.Request('POST', 'http://google.com:80/', '', {})
|
||||
assert False == matchers.method(req_get, req_post)
|
||||
|
||||
|
||||
def test_url():
|
||||
req1 = request.Request('http', 'google.com', 80, 'GET', '/', '', {})
|
||||
req1 = request.Request('GET', 'http://google.com:80/', '', {})
|
||||
assert True == matchers.url(req1, req1)
|
||||
|
||||
req2 = request.Request('http', 'httpbin.org', 80, 'GET', '/', '', {})
|
||||
req2 = request.Request('GET', 'https://httpbin.org:80/', '', {})
|
||||
assert False == matchers.url(req1, req2)
|
||||
|
||||
req1_post = request.Request('http', 'google.com', 80, 'POST', '/', '', {})
|
||||
req1_post = request.Request('POST', 'http://google.com:80/', '', {})
|
||||
assert True == matchers.url(req1, req1_post)
|
||||
|
||||
req_query_string = request.Request(
|
||||
'http', 'google.com?p1=t1&p2=t2', 80, 'GET', '/', '', {})
|
||||
'GET', 'http://google.com:80/?p1=t1&p2=t2', '', {})
|
||||
req_query_string1 = request.Request(
|
||||
'http', 'google.com?p2=t2&p1=t1', 80, 'GET', '/', '', {})
|
||||
'GET', 'http://google.com:80/?p2=t2&p1=t1', '', {})
|
||||
assert False == matchers.url(req_query_string, req_query_string1)
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
from vcr.request import Request
|
||||
|
||||
|
||||
def test_url():
|
||||
req = Request('http', 'www.google.com', 80, 'GET', '/', '', {})
|
||||
assert req.url == 'http://www.google.com/'
|
||||
|
||||
|
||||
def test_str():
|
||||
req = Request('http', 'www.google.com', 80, 'GET', '/', '', {})
|
||||
str(req) == '<Request (GET) http://www.google.com>'
|
||||
req = Request('GET', 'http://www.google.com:80/', '', {})
|
||||
str(req) == '<Request (GET) http://www.google.com:80/>'
|
||||
|
||||
Reference in New Issue
Block a user