Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -7,20 +7,17 @@ from _pytest.monkeypatch import MonkeyPatch
|
||||
|
||||
|
||||
class MockedHttp:
|
||||
def httpx_request(method: Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'],
|
||||
url: str, **kwargs) -> httpx.Response:
|
||||
def httpx_request(
|
||||
method: Literal["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"], url: str, **kwargs
|
||||
) -> httpx.Response:
|
||||
"""
|
||||
Mocked httpx.request
|
||||
"""
|
||||
request = httpx.Request(
|
||||
method,
|
||||
url,
|
||||
params=kwargs.get('params'),
|
||||
headers=kwargs.get('headers'),
|
||||
cookies=kwargs.get('cookies')
|
||||
method, url, params=kwargs.get("params"), headers=kwargs.get("headers"), cookies=kwargs.get("cookies")
|
||||
)
|
||||
data = kwargs.get('data', None)
|
||||
resp = json.dumps(data).encode('utf-8') if data else b'OK'
|
||||
data = kwargs.get("data", None)
|
||||
resp = json.dumps(data).encode("utf-8") if data else b"OK"
|
||||
response = httpx.Response(
|
||||
status_code=200,
|
||||
request=request,
|
||||
|
Reference in New Issue
Block a user