23 lines
637 B
Python
23 lines
637 B
Python
|
|
"""Test the connection utils in `velofy.db.connection`."""
|
||
|
|
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
from velofy import config as pkg_config
|
||
|
|
from velofy.db import connection
|
||
|
|
|
||
|
|
|
||
|
|
def test_engine_uses_the_configured_database():
|
||
|
|
"""`get_engine()` connects to the `DATABASE_URI`."""
|
||
|
|
result = connection.get_engine()
|
||
|
|
|
||
|
|
assert result.url == sa.make_url(pkg_config.DATABASE_URI)
|
||
|
|
|
||
|
|
|
||
|
|
def test_session_is_bound_to_the_engine():
|
||
|
|
"""The `session` proxy creates sessions bound to `get_engine()`."""
|
||
|
|
session = connection.session()
|
||
|
|
|
||
|
|
try:
|
||
|
|
assert session.get_bind() is connection.get_engine()
|
||
|
|
finally:
|
||
|
|
connection.session.remove()
|