1
0
mirror of https://github.com/httpie/cli.git synced 2026-06-20 11:32:56 +02:00

Added --show-redirects and --max-redirects

Closes #157, #183, #188, #246
This commit is contained in:
Jakub Roztocil
2016-02-29 13:56:21 +08:00
parent c6d4f6cdf6
commit 356e043651
7 changed files with 76 additions and 18 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ def patharg(path):
return path.replace('\\', '\\\\\\')
FIXTURES_ROOT = path.join(path.abspath(path.dirname(__file__)), 'fixtures')
FIXTURES_ROOT = path.join(path.abspath(path.dirname(__file__)))
FILE_PATH = path.join(FIXTURES_ROOT, 'test.txt')
JSON_FILE_PATH = path.join(FIXTURES_ROOT, 'test.json')
BIN_FILE_PATH = path.join(FIXTURES_ROOT, 'test.bin')
+22
View File
@@ -0,0 +1,22 @@
"""High-level tests."""
from httpie import ExitStatus
from utils import http, HTTP_OK
class TestRedirects:
def test_follow_no_show_redirects(self, httpbin):
r = http('--follow', httpbin.url + '/redirect/2')
assert r.count('HTTP/1.1') == 1
assert HTTP_OK in r
def test_follow_show_redirects(self, httpbin):
r = http('--follow', '--show-redirects', httpbin.url + '/redirect/2')
assert r.count('HTTP/1.1') == 3
assert r.count('HTTP/1.1 302 FOUND', 2)
assert HTTP_OK in r
def test_max_redirects(self, httpbin):
r = http('--max-redirects=2', '--follow', httpbin.url + '/redirect/3',
error_exit_ok=True)
assert r.exit_status == ExitStatus.ERROR_TOO_MANY_REDIRECTS