NOTE
This issue is here because the work has already been done for my own project here, but enough changes have been made to the point where I think it may be useful for pydis to reap the benefits as well.
Description
Initially, I took the mocks for my own project, and added a few mocks that I needed, but while working through them, I noticed some shortcomings. Those shortcomings are addressed in the file change I made.
A short list of changes are as follows:
- add discord.Thread mock
- make mocks NonCallable mocks since you cannot call a message (or any) instance
- ensure mock returns return the correct type, eg channel.send() will return a MockMessage
The most important part of the changes is the final change. This uses the typing information provided by discord.py in order to mock all functions that are mockable to return the correct mock type when they are called. This means that message.create_thread() will return a MockThread, or channel.send() will return a MockMessage. This is all done by utilising the typing system, and the fact that the public api of dpy 2 is typed.
NOTE
This issue is here because the work has already been done for my own project here, but enough changes have been made to the point where I think it may be useful for pydis to reap the benefits as well.
Description
Initially, I took the mocks for my own project, and added a few mocks that I needed, but while working through them, I noticed some shortcomings. Those shortcomings are addressed in the file change I made.
A short list of changes are as follows:
The most important part of the changes is the final change. This uses the typing information provided by discord.py in order to mock all functions that are mockable to return the correct mock type when they are called. This means that message.create_thread() will return a MockThread, or channel.send() will return a MockMessage. This is all done by utilising the typing system, and the fact that the public api of dpy 2 is typed.