miki725 / alchemy-mock

SQLAlchemy mock helpers.
Other
82 stars 15 forks source link

UnifiedAlchemyMagicMock should support execute #29

Open ribeaud opened 5 years ago

ribeaud commented 5 years ago

Using session, it is possible to execute plain SQL calls with execute method:

session.execute("select count(*) as count from my_table").fetchone[0]

I did not find out how I could mock such scenarios with UnifiedAlchemyMagicMock. Did I oversee something?

ribeaud commented 5 years ago

Sorry to insist... But is there any workaround to overcome such cases?

miki725 commented 5 years ago

you can mock a session with regular AlchemyMagicMock. unified is meant to mimick orm where you interface with models. not sure how useful that will be to add support there for execute as there is nothing to unify (e.g. there is no need to call execute() multiple times where the params need to be merged).