From 3b0c8164fd68979601856c101da10499d6c166ad Mon Sep 17 00:00:00 2001 From: abondar Date: Fri, 26 Jul 2024 19:51:28 +0300 Subject: [PATCH] Switch tests back to aiomysql --- Makefile | 2 +- tests/backends/test_mysql.py | 10 +++++++++- tests/schema/test_generate_schema.py | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a1d63171b..fbaf7ec99 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ up: @poetry update deps: - @poetry install -E asyncpg -E aiomysql -E asyncmy -E accel -E psycopg -E asyncodbc + @poetry install -E asyncpg -E aiomysql -E accel -E psycopg -E asyncodbc check: deps build ifneq ($(shell which black),) diff --git a/tests/backends/test_mysql.py b/tests/backends/test_mysql.py index 6f92a153e..8dd72133a 100644 --- a/tests/backends/test_mysql.py +++ b/tests/backends/test_mysql.py @@ -6,7 +6,6 @@ from tortoise import Tortoise from tortoise.contrib import test -from tortoise.contrib.test.condition import NotIn class TestMySQL(test.SimpleTestCase): @@ -27,6 +26,15 @@ async def test_bad_charset(self): with self.assertRaisesRegex(ConnectionError, "Unknown charset"): await Tortoise.init(self.db_config, _create_db=True) + async def test_ssl_true(self): + self.db_config["connections"]["models"]["credentials"]["ssl"] = True + try: + await Tortoise.init(self.db_config, _create_db=True) + except (ConnectionError, ssl.SSLError): + pass + else: + self.assertFalse(True, "Expected ConnectionError or SSLError") + async def test_ssl_custom(self): # Expect connectionerror or pass ctx = ssl.create_default_context() diff --git a/tests/schema/test_generate_schema.py b/tests/schema/test_generate_schema.py index f3bb1342f..ddb331381 100644 --- a/tests/schema/test_generate_schema.py +++ b/tests/schema/test_generate_schema.py @@ -406,7 +406,7 @@ async def test_m2m_no_auto_create(self): class TestGenerateSchemaMySQL(TestGenerateSchema): async def init_for(self, module: str, safe=False) -> None: try: - with patch("asyncmy.create_pool", new=MagicMock()): + with patch("aiomysql.create_pool", new=MagicMock()): await Tortoise.init( { "connections": { @@ -428,7 +428,7 @@ async def init_for(self, module: str, safe=False) -> None: ) self.sqls = get_schema_sql(connections.get("default"), safe).split("; ") except ImportError: - raise test.SkipTest("asyncmy not installed") + raise test.SkipTest("aiomysql not installed") async def test_noid(self): await self.init_for("tests.testmodels")