test_config.py
This file
Path
tests/test_config.py
106 lines · 3.1 KiB · Python
Last changed by
http3 (#86)Tom Christiebefore adoptionc9747aa
History of this fileTake it
Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 1why, one step back1import osFinessing interfaceTom Christiebefore adoptiond7619a9
lines 2–5why, one step back2import ssl34import pytest5http3 (#86)Tom Christiebefore adoptionc9747aa
line 6why, one step back6import http3Finessing interfaceTom Christiebefore adoptiond7619a9
lines 7–10why, one step back789@pytest.mark.asyncio10async def test_load_ssl_config():http3 (#86)Tom Christiebefore adoptionc9747aa
line 11why, one step back11 ssl_config = http3.SSLConfig()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 12–13why, one step back12 context = await ssl_config.load_ssl_context()13 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 14–17why, one step back141516@pytest.mark.asyncio17async def test_load_ssl_config_verify_non_existing_path():http3 (#86)Tom Christiebefore adoptionc9747aa
line 18why, one step back18 ssl_config = http3.SSLConfig(verify="/path/to/nowhere")Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 19–24why, one step back19 with pytest.raises(IOError):20 await ssl_config.load_ssl_context()212223@pytest.mark.asyncio24async def test_load_ssl_config_verify_existing_file():http3 (#86)Tom Christiebefore adoptionc9747aa
line 25why, one step back25 ssl_config = http3.SSLConfig(verify=http3.config.DEFAULT_CA_BUNDLE_PATH)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 26–31why, one step back26 context = await ssl_config.load_ssl_context()27 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED282930@pytest.mark.asyncio31async def test_load_ssl_config_verify_directory():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 32–33why, one step back32 path = os.path.dirname(http3.config.DEFAULT_CA_BUNDLE_PATH)33 ssl_config = http3.SSLConfig(verify=path)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 34–40why, one step back34 context = await ssl_config.load_ssl_context()35 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED363738@pytest.mark.asyncio39async def test_load_ssl_config_cert_and_key(cert_and_key_paths):40 cert_path, key_path = cert_and_key_pathshttp3 (#86)Tom Christiebefore adoptionc9747aa
line 41why, one step back41 ssl_config = http3.SSLConfig(cert=(cert_path, key_path))Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 42–48why, one step back42 context = await ssl_config.load_ssl_context()43 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED444546@pytest.mark.asyncio47async def test_load_ssl_config_cert_without_key_raises(cert_and_key_paths):48 cert_path, _ = cert_and_key_pathshttp3 (#86)Tom Christiebefore adoptionc9747aa
line 49why, one step back49 ssl_config = http3.SSLConfig(cert=cert_path)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 50–51why, one step back50 with pytest.raises(ssl.SSLError):51 await ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 52–55why, one step back525354@pytest.mark.asyncio55async def test_load_ssl_config_no_verify(verify=False):http3 (#86)Tom Christiebefore adoptionc9747aa
line 56why, one step back56 ssl_config = http3.SSLConfig(verify=False)Finessing interfaceTom Christiebefore adoptiond7619a9
lines 57–58why, one step back57 context = await ssl_config.load_ssl_context()58 assert context.verify_mode == ssl.VerifyMode.CERT_NONEMerge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 59–61why, one step back596061def test_ssl_repr():http3 (#86)Tom Christiebefore adoptionc9747aa
line 62why, one step back62 ssl = http3.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 63–66why, one step back63 assert repr(ssl) == "SSLConfig(cert=None, verify=False)"646566def test_timeout_repr():http3 (#86)Tom Christiebefore adoptionc9747aa
line 67why, one step back67 timeout = http3.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 68–69why, one step back68 assert repr(timeout) == "TimeoutConfig(timeout=5.0)"69http3 (#86)Tom Christiebefore adoptionc9747aa
line 70why, one step back70 timeout = http3.TimeoutConfig(read_timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 71–72why, one step back71 assert (72 repr(timeout)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 73why, one step back73 == "TimeoutConfig(connect_timeout=None, read_timeout=5.0, write_timeout=None)"Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 74–77why, one step back74 )757677def test_limits_repr():http3 (#86)Tom Christiebefore adoptionc9747aa
line 78why, one step back78 limits = http3.PoolLimits(hard_limit=100)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 79–81why, one step back79 assert (80 repr(limits) == "PoolLimits(soft_limit=None, hard_limit=100, pool_timeout=None)"81 )Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 82–84why, one step back828384def test_ssl_eq():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 85–86why, one step back85 ssl = http3.SSLConfig(verify=False)86 assert ssl == http3.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 87–89why, one step back878889def test_timeout_eq():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 90–91why, one step back90 timeout = http3.TimeoutConfig(timeout=5.0)91 assert timeout == http3.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 92–94why, one step back929394def test_limits_eq():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 95–96why, one step back95 limits = http3.PoolLimits(hard_limit=100)96 assert limits == http3.PoolLimits(hard_limit=100)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 97–99why, one step back979899def test_timeout_from_tuple():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 100–101why, one step back100 timeout = http3.TimeoutConfig(timeout=(5.0, 5.0, 5.0))101 assert timeout == http3.TimeoutConfig(timeout=5.0)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 102–104why, one step back102103104def test_timeout_from_config_instance():http3 (#86)Tom Christiebefore adoptionc9747aa
lines 105–106why, one step back105 timeout = http3.TimeoutConfig(timeout=(5.0))106 assert http3.TimeoutConfig(timeout) == http3.TimeoutConfig(timeout=5.0)