MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / test_ssl_custom

Function test_ssl_custom

tests/backends/test_postgres.py:99–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97
98@pytest.mark.asyncio
99async def test_ssl_custom():
100 db_config, is_asyncpg, is_psycopg = _get_db_config()
101 if not is_asyncpg and not is_psycopg:
102 pytest.skip("PostgreSQL only")
103
104 # Expect connectionerror or pass
105 ssl_ctx = ssl.create_default_context()
106 ssl_ctx.check_hostname = False
107 ssl_ctx.verify_mode = ssl.CERT_NONE
108
109 db_config["connections"]["models"]["credentials"]["ssl"] = ssl_ctx
110 ssl_failed = False
111 try:
112 await Tortoise.init(db_config, _create_db=True)
113 except ConnectionError:
114 ssl_failed = True
115 finally:
116 # Don't try to drop database if SSL connection failed - we can't connect
117 if Tortoise._inited and not ssl_failed:
118 await Tortoise._drop_databases()
119
120
121@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 3

_drop_databasesMethod · 0.80
_get_db_configFunction · 0.70
initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…