From 3228e74df5792c621850dfba2a4d78fbca8f6aaf Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Tue, 15 Jun 2021 17:24:26 +0200 Subject: [PATCH] Add `--follow --verbose` test for HTTP 308 --- tests/test_redirects.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_redirects.py b/tests/test_redirects.py index 1bf15ef6..dff3d70f 100644 --- a/tests/test_redirects.py +++ b/tests/test_redirects.py @@ -68,10 +68,18 @@ def test_http_307_allow_redirect_post(httpbin): assert HTTP_OK in r -def test_http_307_allow_redirect_post_verbose(httpbin): - r = http('--follow', '--verbose', 'POST', httpbin.url + '/redirect-to', - f'url=={httpbin.url}/post', 'status_code==307', - '@' + FILE_PATH_ARG) +@pytest.mark.parametrize('status_code', [307, 308]) +def test_verbose_follow_redirect_with_repost(httpbin, status_code): + # + r = http( + '--follow', + '--verbose', + httpbin.url + '/redirect-to', + f'url=={httpbin.url}/post', + f'status_code=={status_code}', + '@' + FILE_PATH_ARG, + ) + assert f'HTTP/1.1 {status_code}' in r assert r.count('POST /redirect-to') == 1 assert r.count('POST /post') == 1 assert r.count(FILE_CONTENT) == 3 # two requests + final response contain it