mirror of
https://github.com/httpie/cli.git
synced 2024-11-25 09:13:25 +01:00
accept wip
This commit is contained in:
parent
3af5f1f305
commit
83bd8059de
@ -2,7 +2,7 @@
|
|||||||
Tests for the provided defaults regarding HTTP method, and --json vs. --form.
|
Tests for the provided defaults regarding HTTP method, and --json vs. --form.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from httpie.client import JSON_ACCEPT
|
from httpie.client import EXPLICIT_JSON_ACCEPT, AUTO_JSON_ACCEPT
|
||||||
from utils import MockEnvironment, http, HTTP_OK
|
from utils import MockEnvironment, http, HTTP_OK
|
||||||
from fixtures import FILE_PATH
|
from fixtures import FILE_PATH
|
||||||
|
|
||||||
@ -75,20 +75,20 @@ class TestAutoContentTypeAndAcceptHeaders:
|
|||||||
def test_POST_with_data_auto_JSON_headers(self, httpbin):
|
def test_POST_with_data_auto_JSON_headers(self, httpbin):
|
||||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.json['headers']['Accept'] == JSON_ACCEPT
|
assert r.json['headers']['Accept'] == AUTO_JSON_ACCEPT
|
||||||
assert r.json['headers']['Content-Type'] == 'application/json'
|
assert r.json['headers']['Content-Type'] == 'application/json'
|
||||||
|
|
||||||
def test_GET_with_data_auto_JSON_headers(self, httpbin):
|
def test_GET_with_data_auto_JSON_headers(self, httpbin):
|
||||||
# JSON headers should automatically be set also for GET with data.
|
# JSON headers should automatically be set also for GET with data.
|
||||||
r = http('POST', httpbin.url + '/post', 'a=b')
|
r = http('POST', httpbin.url + '/post', 'a=b')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.json['headers']['Accept'] == JSON_ACCEPT
|
assert r.json['headers']['Accept'] == AUTO_JSON_ACCEPT
|
||||||
assert r.json['headers']['Content-Type'] == 'application/json'
|
assert r.json['headers']['Content-Type'] == 'application/json'
|
||||||
|
|
||||||
def test_POST_explicit_JSON_JSON_ACCEPT(self, httpbin):
|
def test_POST_explicit_JSON_JSON_ACCEPT(self, httpbin):
|
||||||
r = http('--json', 'POST', httpbin.url + '/post')
|
r = http('--json', 'POST', httpbin.url + '/post')
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert r.json['headers']['Accept'] == JSON_ACCEPT
|
assert r.json['headers']['Accept'] == EXPLICIT_JSON_ACCEPT
|
||||||
# Make sure Content-Type gets set even with no data.
|
# Make sure Content-Type gets set even with no data.
|
||||||
# https://github.com/jakubroztocil/httpie/issues/137
|
# https://github.com/jakubroztocil/httpie/issues/137
|
||||||
assert 'application/json' in r.json['headers']['Content-Type']
|
assert 'application/json' in r.json['headers']['Content-Type']
|
||||||
|
Loading…
Reference in New Issue
Block a user