Skip to content

Commit

Permalink
Switch tests back to aiomysql
Browse files Browse the repository at this point in the history
  • Loading branch information
abondar committed Jul 26, 2024
1 parent 33d06e2 commit 3b0c816
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
Expand Down
10 changes: 9 additions & 1 deletion tests/backends/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from tortoise import Tortoise
from tortoise.contrib import test
from tortoise.contrib.test.condition import NotIn


class TestMySQL(test.SimpleTestCase):
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/schema/test_generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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")
Expand Down

0 comments on commit 3b0c816

Please sign in to comment.