def test_initialize_db(self, mock_base): testManager = SessionManager() mock_engine = MagicMock() mock_engine.dialect.has_table.return_value = None testManager.engine = mock_engine testManager.initializeDatabase() mock_base.metadata.create_all.assert_called_once_with(mock_engine)
def test_close_connection(self, mock_commit): mock_session = MagicMock() mock_engine = MagicMock() testManager = SessionManager() testManager.session = mock_session testManager.engine = mock_engine testManager.closeConnection() mock_commit.assert_called_once() mock_session.close.assert_called_once() mock_engine.dispose.assert_called_once()