You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
* Make sure there’s no trailing \n in test files for easier output inspection * Refactor output matching test utils * More robust `test_http_307_allow_redirect_post_verbose()` * Changelog * Mention HTTP 307 Temporary Redirect re-post behaviour in README
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
"""
|
||||
Utilities for testing output composition.
|
||||
|
||||
"""
|
||||
from typing import Iterable
|
||||
|
||||
import pytest
|
||||
|
||||
from .parsing import OutputMatchingError, expect_tokens, Expect
|
||||
from .parsing import OutputMatchingError, expect_tokens
|
||||
from .tokens import Expect, ExpectSequence
|
||||
|
||||
|
||||
__all__ = [
|
||||
'assert_output_matches',
|
||||
'assert_output_does_not_match',
|
||||
'Expect',
|
||||
'ExpectSequence',
|
||||
]
|
||||
|
||||
|
||||
|
@@ -1,22 +1,11 @@
|
||||
import re
|
||||
from typing import Iterable
|
||||
from enum import Enum, auto
|
||||
|
||||
from httpie.output.writer import MESSAGE_SEPARATOR
|
||||
from .tokens import Expect
|
||||
from ...utils import CRLF
|
||||
|
||||
|
||||
class Expect(Enum):
|
||||
"""
|
||||
Predefined token types we can expect in the output.
|
||||
|
||||
"""
|
||||
REQUEST_HEADERS = auto()
|
||||
RESPONSE_HEADERS = auto()
|
||||
BODY = auto()
|
||||
SEPARATOR = auto()
|
||||
|
||||
|
||||
SEPARATOR_RE = re.compile(f'^{MESSAGE_SEPARATOR}')
|
||||
|
||||
|
||||
|
51
tests/utils/matching/tokens.py
Normal file
51
tests/utils/matching/tokens.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from enum import Enum, auto
|
||||
|
||||
|
||||
class Expect(Enum):
|
||||
"""
|
||||
Predefined token types we can expect in the output.
|
||||
|
||||
"""
|
||||
REQUEST_HEADERS = auto()
|
||||
RESPONSE_HEADERS = auto()
|
||||
BODY = auto()
|
||||
SEPARATOR = auto()
|
||||
|
||||
|
||||
class ExpectSequence:
|
||||
"""
|
||||
Standard combined chunks. These predefined requests and responses assume a body.
|
||||
|
||||
"""
|
||||
RAW_REQUEST = [
|
||||
Expect.REQUEST_HEADERS,
|
||||
Expect.BODY,
|
||||
]
|
||||
RAW_RESPONSE = [
|
||||
Expect.RESPONSE_HEADERS,
|
||||
Expect.BODY,
|
||||
]
|
||||
RAW_EXCHANGE = [
|
||||
*RAW_REQUEST,
|
||||
Expect.SEPARATOR, # Good choice?
|
||||
*RAW_RESPONSE,
|
||||
]
|
||||
RAW_BODY = [
|
||||
Expect.BODY,
|
||||
]
|
||||
TERMINAL_REQUEST = [
|
||||
*RAW_REQUEST,
|
||||
Expect.SEPARATOR,
|
||||
]
|
||||
TERMINAL_RESPONSE = [
|
||||
*RAW_RESPONSE,
|
||||
Expect.SEPARATOR,
|
||||
]
|
||||
TERMINAL_EXCHANGE = [
|
||||
*TERMINAL_REQUEST,
|
||||
*TERMINAL_RESPONSE,
|
||||
]
|
||||
TERMINAL_BODY = [
|
||||
RAW_BODY,
|
||||
Expect.SEPARATOR
|
||||
]
|
Reference in New Issue
Block a user