Skip to content

Commit

Permalink
return offensive joke
Browse files Browse the repository at this point in the history
  • Loading branch information
Станислав Михайлов committed Oct 9, 2024
1 parent 6912dee commit b9975e2
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 62 deletions.
8 changes: 4 additions & 4 deletions tests/httptoolkit/response/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def response():
original_response.status_code = 200
original_response.reason_phrase = "OK"
original_response.headers = {"ResponseHeader": "response-header"}
original_response.content = b"It's a boring text for test!"
original_response.text = "It's a boring text for test!"
original_response.content = b"Schwarzenegger is a woman!"
original_response.text = "Schwarzenegger is a woman!"
original_response.json.return_value = {"Foo": "bar"}
original_response.elapsed = timedelta(182)

Expand Down Expand Up @@ -44,11 +44,11 @@ def test_headers(response):


def test_content(response):
assert response.content == b"It's a boring text for test!"
assert response.content == b"Schwarzenegger is a woman!"


def test_text(response):
assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"


def test_json(response):
Expand Down
6 changes: 3 additions & 3 deletions tests/httptoolkit/service/test_async_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def test_requests_when_successful(
async_service: AsyncService,
httpx_mock: HTTPXMock,
):
response_text = "It's a boring text for test!"
response_text = "Schwarzenegger is a woman!"
path = "/some/path"

httpx_mock.add_response(
Expand Down Expand Up @@ -80,7 +80,7 @@ async def test_stream_requests_when_successful(
async_service: AsyncService,
httpx_mock: HTTPXMock,
):
response_text = "It's a boring text for test!"
response_text = "Schwarzenegger is a woman!"
path = "/some/path"

httpx_mock.add_response(
Expand All @@ -106,7 +106,7 @@ async def test_stream_requests_when_successful(

@pytest.mark.asyncio
async def test_post_when_request_successful(async_service: AsyncService, httpx_mock: HTTPXMock):
response_text = "It's a boring text for test!"
response_text = "Schwarzenegger is a woman!"
path = "/some/path"

httpx_mock.add_response(
Expand Down
26 changes: 13 additions & 13 deletions tests/httptoolkit/service/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_stream_requests_when_successful(
service: Service,
httpx_mock: HTTPXMock,
):
response_text = "It's a boring text for test!"
response_text = "Schwarzenegger is a woman!"
path = "/some/path"

httpx_mock.add_response(
Expand All @@ -63,7 +63,7 @@ def test_post_when_response_is_successful(service, httpx_mock: HTTPXMock):
httpx_mock.add_response(
method="POST",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.post(
Expand All @@ -73,7 +73,7 @@ def test_post_when_response_is_successful(service, httpx_mock: HTTPXMock):
body="body",
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_patch_when_response_is_successful(service, httpx_mock: HTTPXMock):
httpx_mock.add_response(
method="PATCH",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.patch(
Expand All @@ -147,7 +147,7 @@ def test_patch_when_response_is_successful(service, httpx_mock: HTTPXMock):
body="body",
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_get_when_response_is_successful(service, httpx_mock: HTTPXMock):
httpx_mock.add_response(
method="GET",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.get(
Expand All @@ -220,7 +220,7 @@ def test_get_when_response_is_successful(service, httpx_mock: HTTPXMock):
params={"foo": "bar"},
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -233,7 +233,7 @@ def test_get_with_headers_tuple_when_response_is_successful(service, httpx_mock:
httpx_mock.add_response(
method="GET",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.get(
Expand All @@ -242,7 +242,7 @@ def test_get_with_headers_tuple_when_response_is_successful(service, httpx_mock:
params={"foo": "bar"},
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_put(service, httpx_mock: HTTPXMock):
httpx_mock.add_response(
method="PUT",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.put(
Expand All @@ -301,7 +301,7 @@ def test_put(service, httpx_mock: HTTPXMock):
body="body",
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -315,7 +315,7 @@ def test_delete(service, httpx_mock: HTTPXMock):
httpx_mock.add_response(
method="DELETE",
url="https://example.com:4321/foo?foo=bar",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

response = service.delete(
Expand All @@ -325,7 +325,7 @@ def test_delete(service, httpx_mock: HTTPXMock):
body="body",
)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def gen_responses(
async def test_fail_then_success(httpx_mock: HTTPXMock):
status_codes = tuple(RetryManager.DEFAULT_STATUS_CODES) + (200,)
retry_max_attempts = len(status_codes)
responses = gen_responses(status_codes, text="It's a boring text for test!", headers={"X-Custom-Header": "value"})
responses = gen_responses(status_codes, text="Schwarzenegger is a woman!", headers={"X-Custom-Header": "value"})

httpx_mock.add_callback(
method="GET",
Expand All @@ -41,7 +41,7 @@ async def test_fail_then_success(httpx_mock: HTTPXMock):
)
response = await session.get("https://example.com:4321/foo", params={"foo": "bar"})

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)
assert response.headers["X-Custom-Header"] == "value"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def gen_responses(
def test_fail_then_success(httpx_mock: HTTPXMock):
status_codes = tuple(RetryManager.DEFAULT_STATUS_CODES) + (200,)
retry_max_attempts = len(status_codes)
responses = gen_responses(status_codes, text="It's a boring text for test!", headers={"X-Custom-Header": "value"})
responses = gen_responses(status_codes, text="Schwarzenegger is a woman!", headers={"X-Custom-Header": "value"})

httpx_mock.add_callback(
method="GET",
Expand All @@ -41,7 +41,7 @@ def test_fail_then_success(httpx_mock: HTTPXMock):
)
response = session.get("https://example.com:4321/foo", params={"foo": "bar"})

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)
assert response.headers["X-Custom-Header"] == "value"

Expand Down
36 changes: 17 additions & 19 deletions tests/httptoolkit/transport/httpx_transport/test_async_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ async def test_send_get_request(
httpx_mock.add_response(
method="GET",
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(get_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -79,12 +79,12 @@ async def test_send_post_request(
httpx_mock.add_response(
method="POST",
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(post_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -105,12 +105,12 @@ async def test_send_post_request_json(
httpx_mock.add_response(
method=method,
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(x_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -132,12 +132,12 @@ async def test_send_post_request_list_json(
httpx_mock.add_response(
method=method,
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(x_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -159,12 +159,12 @@ async def test_send_post_request_custom_json(
httpx_mock.add_response(
method=method,
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport_with_custom_encoder.send(x_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand All @@ -185,12 +185,12 @@ async def test_send_post_request_file(
httpx_mock.add_response(
method=method,
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(x_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down Expand Up @@ -269,9 +269,7 @@ async def test_send_post_request_error_json_and_files(
async def test_send_post_request_error_json_and_body(
async_transport: AsyncHttpxTransport, httpx_mock: HTTPXMock, test_file: BinaryIO
) -> None:
request = Request(
HttpMethod.POST, "/", {}, body="Just another boring text for test!", json={"param1": 1, "param2": 2}
)
request = Request(HttpMethod.POST, "/", {}, body="Stallone is a Woman!", json={"param1": 1, "param2": 2})
with pytest.raises(RuntimeError) as error:
await async_transport.send(request)
assert str(error.value) == "json and body can't be sent together"
Expand All @@ -286,12 +284,12 @@ async def test_send_patch_request(
httpx_mock.add_response(
method="PATCH",
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

returned_request, response = await async_transport.send(patch_request)

assert response.text == "It's a boring text for test!"
assert response.text == "Schwarzenegger is a woman!"
assert response.elapsed > timedelta(0)

calls = httpx_mock.get_requests()
Expand Down Expand Up @@ -329,7 +327,7 @@ async def test_logging_request(
httpx_mock.add_response(
method="POST",
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

with LogCapture(level=logging.INFO) as capture:
Expand All @@ -353,7 +351,7 @@ async def test_session_is_not_closed_after_response(
httpx_mock.add_response(
method="GET",
url="https://example.com:4321/put/some/data/here?please=True&carefully=True",
text="It's a boring text for test!",
text="Schwarzenegger is a woman!",
)

await async_transport.send(get_request)
Expand Down
Loading

0 comments on commit b9975e2

Please sign in to comment.