2014-04-26 15:06:51 +02:00
|
|
|
"""
|
|
|
|
Various unicode handling related tests.
|
|
|
|
|
|
|
|
"""
|
2021-05-05 14:13:39 +02:00
|
|
|
from .utils import http, HTTP_OK
|
|
|
|
from .fixtures import UNICODE
|
2014-04-26 15:06:51 +02:00
|
|
|
|
|
|
|
|
2016-03-03 11:47:12 +01:00
|
|
|
def test_unicode_headers(httpbin):
|
|
|
|
# httpbin doesn't interpret utf8 headers
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http(httpbin.url + '/headers', f'Test:{UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_headers_verbose(httpbin):
|
|
|
|
# httpbin doesn't interpret utf8 headers
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--verbose', httpbin.url + '/headers', f'Test:{UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert UNICODE in r
|
|
|
|
|
|
|
|
|
2021-05-24 14:29:54 +02:00
|
|
|
def test_unicode_raw(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--raw', f'test {UNICODE}', 'POST', httpbin.url + '/post')
|
2021-05-24 14:29:54 +02:00
|
|
|
assert HTTP_OK in r
|
2021-05-26 14:09:38 +02:00
|
|
|
assert r.json['data'] == f'test {UNICODE}'
|
2021-05-24 14:29:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_raw_verbose(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--verbose', '--raw', f'test {UNICODE}',
|
2021-05-24 14:29:54 +02:00
|
|
|
'POST', httpbin.url + '/post')
|
|
|
|
assert HTTP_OK in r
|
|
|
|
assert UNICODE in r
|
|
|
|
|
|
|
|
|
2016-03-03 11:47:12 +01:00
|
|
|
def test_unicode_form_item(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--form', 'POST', httpbin.url + '/post', f'test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['form'] == {'test': UNICODE}
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_form_item_verbose(httpbin):
|
|
|
|
r = http('--verbose', '--form',
|
2021-05-26 14:09:38 +02:00
|
|
|
'POST', httpbin.url + '/post', f'test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert UNICODE in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_json_item(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--json', 'POST', httpbin.url + '/post', f'test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['json'] == {'test': UNICODE}
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_json_item_verbose(httpbin):
|
|
|
|
r = http('--verbose', '--json',
|
2021-05-26 14:09:38 +02:00
|
|
|
'POST', httpbin.url + '/post', f'test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert UNICODE in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_raw_json_item(httpbin):
|
|
|
|
r = http('--json', 'POST', httpbin.url + '/post',
|
2021-05-26 14:09:38 +02:00
|
|
|
f'test:={{ "{UNICODE}" : [ "{UNICODE}" ] }}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['json'] == {'test': {UNICODE: [UNICODE]}}
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_raw_json_item_verbose(httpbin):
|
|
|
|
r = http('--json', 'POST', httpbin.url + '/post',
|
2021-05-26 14:09:38 +02:00
|
|
|
f'test:={{ "{UNICODE}" : [ "{UNICODE}" ] }}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['json'] == {'test': {UNICODE: [UNICODE]}}
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_url_query_arg_item(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http(httpbin.url + '/get', f'test=={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['args'] == {'test': UNICODE}, r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_url_query_arg_item_verbose(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http('--verbose', httpbin.url + '/get', f'test=={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert UNICODE in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_url(httpbin):
|
2021-05-26 14:09:38 +02:00
|
|
|
r = http(f'{httpbin.url}/get?test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
assert HTTP_OK in r
|
|
|
|
assert r.json['args'] == {'test': UNICODE}
|
|
|
|
|
|
|
|
# def test_unicode_url_verbose(self):
|
2021-05-26 14:09:38 +02:00
|
|
|
# r = http(httpbin.url + '--verbose', f'/get?test={UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
# assert HTTP_OK in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_basic_auth(httpbin):
|
|
|
|
# it doesn't really authenticate us because httpbin
|
|
|
|
# doesn't interpret the utf8-encoded auth
|
2021-05-26 14:09:38 +02:00
|
|
|
http('--verbose', '--auth', f'test:{UNICODE}',
|
|
|
|
f'{httpbin.url}/basic-auth/test/{UNICODE}')
|
2016-03-03 11:47:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_unicode_digest_auth(httpbin):
|
|
|
|
# it doesn't really authenticate us because httpbin
|
|
|
|
# doesn't interpret the utf8-encoded auth
|
|
|
|
http('--auth-type=digest',
|
2021-05-26 14:09:38 +02:00
|
|
|
'--auth', f'test:{UNICODE}',
|
|
|
|
f'{httpbin.url}/digest-auth/auth/test/{UNICODE}')
|