cenkalti / github-flask

🍾 Flask extension for GitHub API

Home Page:https://github-flask.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add mocking capability

brizental opened this issue · comments

I have an app that uses this extension and I want to mock the login function for testing. I was thinking that maybe we could add a a flag saying that the app is in test mode or not, if that is the case, then mock everything. I am willing to implement this :)

Hello @brizental. Which function/method do you want to mock? Can you solve your problem using unittest.mock module?

I need to mock the authorize method and the get method, to login and get user info. I can use unittest.mock , but I thought it would be useful to have that built into the extension, instead of only having it in my app. Of course then we would have to mock every request to the GitHub API, not only the ones that I need. What do you think?

Sorry @brizental, I don't want to add this functionality to the extension. I find unittest.mock more suitable for the job.

That's fine @cenkalti . Thanks for the quicl answer :)