-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9714e86
commit 8f676e8
Showing
2 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from ..utils import ensure_specified_sql_driver | ||
|
||
|
||
def test_ensure_specified_sql_driver(): | ||
# Postgres | ||
# Default driver is added if missing. | ||
assert ( | ||
ensure_specified_sql_driver( | ||
"postgresql://user:password@localhost:5432/database" | ||
) | ||
== "postgresql+asyncpg://user:password@localhost:5432/database" | ||
) | ||
# Default driver passes through if specified. | ||
assert ( | ||
ensure_specified_sql_driver( | ||
"postgresql+asyncpg://user:password@localhost:5432/database" | ||
) | ||
== "postgresql+asyncpg://user:password@localhost:5432/database" | ||
) | ||
# Do not override user-provided. | ||
assert ( | ||
ensure_specified_sql_driver( | ||
"postgresql+custom://user:password@localhost:5432/database" | ||
) | ||
== "postgresql+custom://user:password@localhost:5432/database" | ||
) | ||
|
||
# SQLite | ||
# Default driver is added if missing. | ||
assert ( | ||
ensure_specified_sql_driver("sqlite:////test.db") | ||
== "sqlite+aiosqlite:////test.db" | ||
) | ||
# Default driver passes through if specified. | ||
assert ( | ||
ensure_specified_sql_driver("sqlite+aiosqlite:////test.db") | ||
== "sqlite+aiosqlite:////test.db" | ||
) | ||
# Do not override user-provided. | ||
assert ( | ||
ensure_specified_sql_driver("sqlite+custom:////test.db") | ||
== "sqlite+custom:////test.db" | ||
) | ||
# Handle SQLite :memory: URIs | ||
assert ( | ||
ensure_specified_sql_driver("sqlite+aiosqlite://:memory:") | ||
== "sqlite+aiosqlite://:memory:" | ||
) | ||
assert ( | ||
ensure_specified_sql_driver("sqlite://:memory:") | ||
== "sqlite+aiosqlite://:memory:" | ||
) | ||
# Handle SQLite relative URIs | ||
assert ( | ||
ensure_specified_sql_driver("sqlite+aiosqlite:///test.db") | ||
== "sqlite+aiosqlite:///test.db" | ||
) | ||
assert ( | ||
ensure_specified_sql_driver("sqlite:///test.db") | ||
== "sqlite+aiosqlite:///test.db" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters