Skip to content

Commit

Permalink
refactor: rename make / teardown session methods
Browse files Browse the repository at this point in the history
  • Loading branch information
turisesonia committed Jun 5, 2024
1 parent 454d75a commit ef13454
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions fluent_alchemy/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class ScopedSessionHandler:
_session: Optional[scoped_session] = None

@classmethod
def set_engine(cls, engine: Engine):
def make_session(cls, engine: Engine):
if not isinstance(engine, Engine):
raise ValueError("Only support Sqlalchemy Engine Object")

cls._session = scoped_session(sessionmaker(engine))

@classmethod
def remove_scoped_session(cls):
def teardown_session(cls):
if cls._session:
cls._session.remove()
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def _test_session(engine):
engine.echo = APP_DEBUG

Base.metadata.create_all(engine)
Base.set_engine(engine)
Base.make_session(engine)

# yield, to let all tests within the scope run
yield

Base.remove_scoped_session()
Base.teardown_session()
Base.metadata.drop_all(engine)


Expand All @@ -64,7 +64,7 @@ def email(faker):

# # set_up: fill table at beginning of scope
# # populate_purchase_table_with_data(db, data)
# Base.set_engine(
# Base.make_session(
# create_engine(
# # "sqlite:///tests/database/test.db",
# "sqlite:///tests/database/test.db",
Expand All @@ -77,6 +77,6 @@ def email(faker):
# # yield, to let all tests within the scope run
# yield

# Base.remove_scoped_session()
# Base.teardown_session()

# downgrade(alembic_cfg, "base")

0 comments on commit ef13454

Please sign in to comment.