diff options
| author | maxim-yurchuk <[email protected]> | 2024-10-09 12:29:46 +0300 |
|---|---|---|
| committer | maxim-yurchuk <[email protected]> | 2024-10-09 13:14:22 +0300 |
| commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
| tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/pytest-localserver/py3/tests/test_https.py | |
| parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/pytest-localserver/py3/tests/test_https.py')
| -rw-r--r-- | contrib/python/pytest-localserver/py3/tests/test_https.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/python/pytest-localserver/py3/tests/test_https.py b/contrib/python/pytest-localserver/py3/tests/test_https.py new file mode 100644 index 00000000000..4c676d17533 --- /dev/null +++ b/contrib/python/pytest-localserver/py3/tests/test_https.py @@ -0,0 +1,43 @@ +import requests + +from pytest_localserver import https +from pytest_localserver import plugin + + +# define test fixture here again in order to run tests without having to +# install the plugin anew every single time +httpsserver = plugin.httpsserver + + +def test_httpsserver_funcarg(httpsserver): + assert isinstance(httpsserver, https.SecureContentServer) + assert httpsserver.is_alive() + assert httpsserver.server_address + + +def test_server_does_not_serve_file_at_startup(httpsserver): + assert httpsserver.code == 204 + assert httpsserver.content == "" + + +def test_some_content_retrieval(httpsserver): + httpsserver.serve_content("TEST!") + resp = requests.get(httpsserver.url, verify=False) + assert resp.text == "TEST!" + assert resp.status_code == 200 + + +def test_GET_request(httpsserver): + httpsserver.serve_content("TEST!", headers={"Content-type": "text/plain"}) + resp = requests.get(httpsserver.url, headers={"User-Agent": "Test method"}, verify=False) + assert resp.text == "TEST!" + assert resp.status_code == 200 + assert "text/plain" in resp.headers["Content-type"] + + +def test_HEAD_request(httpsserver): + httpsserver.serve_content("TEST!", headers={"Content-type": "text/plain"}) + print(httpsserver.url) + resp = requests.head(httpsserver.url, verify=False) + assert resp.status_code == 200 + assert resp.headers["Content-type"] == "text/plain" |
