test_matching.py (httpie-3.0.0) | : | test_matching.py (httpie-3.0.1) | ||
---|---|---|---|---|
""" | """ | |||
Here we test our output parsing and matching implementation, not HTTPie itself. | Here we test our output parsing and matching implementation, not HTTPie itself. | |||
""" | """ | |||
from httpie.models import ELAPSED_TIME_LABEL | ||||
from httpie.output.writer import MESSAGE_SEPARATOR | from httpie.output.writer import MESSAGE_SEPARATOR | |||
from ...utils import CRLF | from ...utils import CRLF | |||
from . import assert_output_does_not_match, assert_output_matches, Expect | from . import assert_output_does_not_match, assert_output_matches, Expect | |||
def test_assert_output_matches_headers_incomplete(): | def test_assert_output_matches_headers_incomplete(): | |||
assert_output_does_not_match(f'HTTP/1.1{CRLF}', [Expect.RESPONSE_HEADERS]) | assert_output_does_not_match(f'HTTP/1.1{CRLF}', [Expect.RESPONSE_HEADERS]) | |||
def test_assert_output_matches_headers_unterminated(): | def test_assert_output_matches_headers_unterminated(): | |||
assert_output_does_not_match( | assert_output_does_not_match( | |||
( | ( | |||
skipping to change at line 99 | skipping to change at line 100 | |||
f'AAA:BBB{CRLF}{CRLF}' | f'AAA:BBB{CRLF}{CRLF}' | |||
f'CCC{MESSAGE_SEPARATOR}' | f'CCC{MESSAGE_SEPARATOR}' | |||
), | ), | |||
[Expect.RESPONSE_HEADERS, Expect.BODY, Expect.SEPARATOR] | [Expect.RESPONSE_HEADERS, Expect.BODY, Expect.SEPARATOR] | |||
) | ) | |||
def test_assert_output_matches_response_meta(): | def test_assert_output_matches_response_meta(): | |||
assert_output_matches( | assert_output_matches( | |||
( | ( | |||
'Key: Value\n' | 'Key: Value\n' | |||
'Elapsed Time: 3.3s' | f'{ELAPSED_TIME_LABEL}: 3.3s' | |||
), | ), | |||
[Expect.RESPONSE_META] | [Expect.RESPONSE_META] | |||
) | ) | |||
def test_assert_output_matches_whole_response(): | def test_assert_output_matches_whole_response(): | |||
assert_output_matches( | assert_output_matches( | |||
( | ( | |||
f'HTTP/1.1{CRLF}' | f'HTTP/1.1{CRLF}' | |||
f'AAA:BBB{CRLF}' | f'AAA:BBB{CRLF}' | |||
f'{CRLF}' | f'{CRLF}' | |||
f'CCC{MESSAGE_SEPARATOR}' | f'CCC{MESSAGE_SEPARATOR}' | |||
'Elapsed Time: 3.3s' | f'{ELAPSED_TIME_LABEL}: 3.3s' | |||
), | ), | |||
[Expect.RESPONSE_HEADERS, Expect.BODY, Expect.RESPONSE_META] | [Expect.RESPONSE_HEADERS, Expect.BODY, Expect.RESPONSE_META] | |||
) | ) | |||
def test_assert_output_matches_multiple_messages(): | def test_assert_output_matches_multiple_messages(): | |||
assert_output_matches( | assert_output_matches( | |||
( | ( | |||
f'POST / HTTP/1.1{CRLF}' | f'POST / HTTP/1.1{CRLF}' | |||
f'AAA:BBB{CRLF}' | f'AAA:BBB{CRLF}' | |||
f'{CRLF}' | f'{CRLF}' | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 3 lines changed or added |