Пример #1
0
 def test_fails_with_binary_data(self, post_request):
     # shlex.quote doesn't support a bytes object
     # see https://github.com/python/cpython/pull/10871
     post_request.request.headers[
         "Content-Type"] = "application/json; charset=utf-8"
     with pytest.raises(exceptions.CommandError):
         export.httpie_command(post_request)
Пример #2
0
 def test_tcp(self, tcp_flow):
     with pytest.raises(exceptions.CommandError):
         export.httpie_command(tcp_flow)
Пример #3
0
 def test_patch(self, patch_request):
     result = """http PATCH http://address:22/path?query=param 'header:qvalue' 'content-length:7' <<< 'content'"""
     assert export.httpie_command(patch_request) == result
Пример #4
0
 def test_post(self, post_request):
     result = "http POST http://address:22/path 'content-length:256' <<< '{}'".format(
         str(bytes(range(256)))[2:-1]
     )
     assert export.httpie_command(post_request) == result
Пример #5
0
 def test_get(self, get_request):
     result = """http GET http://address:22/path?a=foo&a=bar&b=baz 'header:qvalue' 'content-length:0'"""
     assert export.httpie_command(get_request) == result
Пример #6
0
 def test_post(self, post_request):
     post_request.request.content = b'nobinarysupport'
     result = "http POST http://address:22/path <<< nobinarysupport"
     assert export.httpie_command(post_request) == result
Пример #7
0
 def test_escape_single_quotes_in_body(self):
     request = tflow.tflow(
         req=tutils.treq(method=b'POST', headers=(), content=b"'&#"))
     command = export.httpie_command(request)
     assert shlex.split(command)[-2] == '<<<'
     assert shlex.split(command)[-1] == "'&#"
Пример #8
0
 def test_patch(self, patch_request):
     result = """http PATCH 'http://address:22/path?query=param' 'header: qvalue' <<< content"""
     assert export.httpie_command(patch_request) == result
Пример #9
0
    def test_correct_host_used(self, get_request):
        get_request.request.headers["host"] = "domain:22"

        result = """http GET 'http://domain:22/path?a=foo&a=bar&b=baz' """ \
                 """'header: qvalue' 'host: domain:22'"""
        assert export.httpie_command(get_request) == result
Пример #10
0
 def _get_data(self, data, flow):
     return "{}\n\n{}\nCurl:\n{}\n\nHttpie:\n{}".format(
         data, "-" * 20, curl_command(flow), httpie_command(flow))