コード例 #1
0
ファイル: test_uploads.py プロジェクト: theetherGit/httpie
def test_chunked_stdin_multiple_chunks():
    stdin_bytes = FILE_PATH.read_bytes() + b'\n' + FILE_PATH.read_bytes()
    r = http('--verbose',
             '--chunked',
             HTTPBIN_WITH_CHUNKED_SUPPORT + '/post',
             env=MockEnvironment(
                 stdin=StdinBytesIO(stdin_bytes),
                 stdin_isatty=False,
                 stdout_isatty=True,
             ))
    assert HTTP_OK in r
    assert 'Transfer-Encoding: chunked' in r
    assert r.count(FILE_CONTENT) == 4
コード例 #2
0
ファイル: test_defaults.py プロジェクト: zulfikar18/httpie
 def test_implicit_POST_stdin(self, httpbin):
     env = MockEnvironment(
         stdin_isatty=False,
         stdin=BytesIO(FILE_PATH.read_bytes())
     )
     r = http('--form', httpbin.url + '/post', env=env)
     assert HTTP_OK in r
コード例 #3
0
ファイル: test_httpie.py プロジェクト: yinwin/httpie
def test_POST_stdin(httpbin_both):
    env = MockEnvironment(
        stdin=StdinBytesIO(FILE_PATH.read_bytes()),
        stdin_isatty=False,
    )
    r = http('--form', 'POST', httpbin_both + '/post', env=env)
    assert HTTP_OK in r
    assert FILE_CONTENT in r
コード例 #4
0
ファイル: test_cli.py プロジェクト: zulfikar18/httpie
 def test_ignore_stdin(self, httpbin):
     env = MockEnvironment(
         stdin=StdinBytesIO(FILE_PATH.read_bytes()),
         stdin_isatty=False,
     )
     r = http('--ignore-stdin', '--verbose', httpbin.url + '/get', env=env)
     assert HTTP_OK in r
     assert 'GET /get HTTP' in r, "Don't default to POST."
     assert FILE_CONTENT not in r, "Don't send stdin data."
コード例 #5
0
def test_chunked_stdin():
    r = http('--verbose',
             '--chunked',
             HTTPBIN_WITH_CHUNKED_SUPPORT + '/post',
             env=MockEnvironment(
                 stdin=StdinBytesIO(FILE_PATH.read_bytes()),
                 stdin_isatty=False,
             ))
    assert HTTP_OK in r
    assert 'Transfer-Encoding: chunked' in r
    assert r.count(FILE_CONTENT) == 2
コード例 #6
0
def test_compress_stdin(httpbin_both):
    env = MockEnvironment(
        stdin=StdinBytesIO(FILE_PATH.read_bytes()),
        stdin_isatty=False,
    )
    r = http(
        '--compress',
        '--compress',
        'PATCH',
        httpbin_both + '/patch',
        env=env,
    )
    assert HTTP_OK in r
    assert r.json['headers']['Content-Encoding'] == 'deflate'
    assert_decompressed_equal(r.json['data'], FILE_CONTENT.strip())
    assert not r.json['json']
コード例 #7
0
ファイル: test_httpie.py プロジェクト: yinwin/httpie
def test_form_POST_file_redirected_stdin(httpbin):
    """
    <https://github.com/httpie/httpie/issues/840>

    """
    with open(FILE_PATH) as f:
        r = http(
            '--form',
            'POST',
            httpbin + '/post',
            f'file@{FILE_PATH}',
            tolerate_error_exit_status=True,
            env=MockEnvironment(
                stdin=StdinBytesIO(FILE_PATH.read_bytes()),
                stdin_isatty=False,
            ),
        )
    assert r.exit_status == ExitStatus.ERROR
    assert 'cannot be mixed' in r.stderr