diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-01-14 17:35:23 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 5e777696447f1895d67625c913398795308de31f (patch) | |
tree | 702385b15d18c96a84742c6a2cdd50afd8f47a9d /tests/test_http_request.py | |
parent | 220e254d4d6760ac356a323ed7ed855848767cae (diff) | |
download | wee-slack-5e777696447f1895d67625c913398795308de31f.tar.gz |
Support multiple HTTP headers
Port 3aa2c79 from master into new.
Diffstat (limited to 'tests/test_http_request.py')
-rw-r--r-- | tests/test_http_request.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_http_request.py b/tests/test_http_request.py index 3a2e8cc..57b0c91 100644 --- a/tests/test_http_request.py +++ b/tests/test_http_request.py @@ -1,3 +1,4 @@ +from textwrap import dedent from unittest.mock import MagicMock, patch import pytest @@ -112,6 +113,33 @@ def test_http_request_error_retry_error(): assert excinfo.value.error == "" +def test_http_request_multiple_headers(): + url = "http://example.com" + coroutine = http_request(url, {}, 0) + future = coroutine.send(None) + assert isinstance(future, FutureProcess) + + response = "response" + body = ( + dedent( + f""" + HTTP/1.1 200 Connection established + + HTTP/2 200 + content-type: application/json; charset=utf-8 + + {response} + """ + ) + .strip() + .replace("\n", "\r\n") + ) + + with pytest.raises(StopIteration) as excinfo: + coroutine.send(("", 0, body, "")) + assert excinfo.value.value == response + + @patch.object(weechat, "hook_timer") def test_http_request_ratelimit(mock_method: MagicMock): url = "http://example.com" @@ -127,5 +155,7 @@ def test_http_request_ratelimit(mock_method: MagicMock): assert isinstance(coroutine.send((0,)), FutureProcess) - with pytest.raises(StopIteration): - coroutine.send(("", 0, "HTTP/2 200\r\n\r\n", "")) + response = "response" + with pytest.raises(StopIteration) as excinfo: + coroutine.send(("", 0, f"HTTP/2 200\r\n\r\n{response}", "")) + assert excinfo.value.value == response |