def test_initialize(self, mock_session, mock_create_engine): config = {'DB_URL': 'postgresql://*****:*****@localhost/mydb'} engine = meta.initialize(config) mock_create_engine.assert_called_once_with(config['DB_URL'], echo=False) self.assertEqual(engine, mock_create_engine.return_value) mock_session.configure.assert_called_once_with(bind=engine)
def test_initalize_sqlite(self, mock_session, mock_listen, mock_create_engine): config = {"DB_URL": "sqlite://", "SQL_DEBUG": True} engine = meta.initialize(config) mock_create_engine.assert_called_once_with(config["DB_URL"], echo=True) mock_session.configure.assert_called_once_with(bind=engine) self.assertEqual(1, mock_listen.call_count) self.assertEqual(engine, mock_listen.call_args_list[0][0][0]) self.assertEqual("connect", mock_listen.call_args_list[0][0][1])
def test_initalize_sqlite(self, mock_session, mock_listen, mock_create_engine): config = {'DB_URL': 'sqlite://', 'SQL_DEBUG': True} engine = meta.initialize(config) mock_create_engine.assert_called_once_with(config['DB_URL'], echo=True) mock_session.configure.assert_called_once_with(bind=engine) self.assertEqual(1, mock_listen.call_count) self.assertEqual(engine, mock_listen.call_args_list[0][0][0]) self.assertEqual('connect', mock_listen.call_args_list[0][0][1])
def test_initialize(self, mock_session, mock_create_engine): config = {"DB_URL": "postgresql://*****:*****@localhost/mydb"} engine = meta.initialize(config) mock_create_engine.assert_called_once_with(config["DB_URL"], echo=False) self.assertEqual(engine, mock_create_engine.return_value) mock_session.configure.assert_called_once_with(bind=engine)