yanyongyu / githubkit

The modern, all-batteries-included GitHub SDK for Python, including rest api, graphql, webhooks, like octokit!
MIT License
173 stars 24 forks source link

Mock REST-API call #138

Open mattibo opened 2 days ago

mattibo commented 2 days ago

Hi,

thank you for the wonderful library. I use it quite a lot. Right now I would like to write a unit test for my own logic. Inside my logic I call the GitHub REST-API with githubkit. I did not manage to mock a call like

github.rest.repos.get(owner="owner", repo="repo")

I tried it like this: https://stackoverflow.com/questions/39457108/how-to-mock-nested-multiple-layers-of-return-objects-in-python

Do you have a tip how to mock githubkit?

yanyongyu commented 2 days ago

It seems you need to mock the githubkit's request and return the fake response data to your code. I think you can monkey patch the request function of the github instance.