def setUp(self) -> None:
"""
Overload the getter for SQLAlchemy sessions for a given database
model with a mock. This method should work similarly to
``Session.object_session``, which returns the SQLAlchemy ORM session
to which the model class is bound
"""
TestService.setUp(self)
self.session_getter = mock.MagicMock(spec=Session.object_session)
self.service = Service(
self.database_service, session_getter_for_model=self.session_getter
)
评论列表
文章目录