Skip to content

Feature Request: Fake Twilio Client #821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
qdii opened this issue Nov 2, 2024 · 2 comments
Open

Feature Request: Fake Twilio Client #821

qdii opened this issue Nov 2, 2024 · 2 comments
Labels
priority: low Nice-to-have; can wait status: waiting for feature feature will be implemented in the future status: waiting for feedback waiting for feedback from the submitter

Comments

@qdii
Copy link

qdii commented Nov 2, 2024

Issue Summary

Properly testing client code against Twilio python library isn't easy. None of the solutions I have found so far allow to run tests with good coverage that are reproducible and hermetic:

  • This blog post suggests mocking the entire client, but this methodology fails to catch problems such as calling client.messages.send() with invalid parameters or function names.
  • This feature request suggests to use localhost instead of api.twilio.com, but this means reverse-engineering the protocol used to talk to api.twilio.com and maintaining a server running just for tests.
  • The option to use responses python package to mock POST and GET requests to api.twilio.com is also very brittle, as the tests would break every time the client is changed. It also takes reverse engineering to know what the client expects.
  • Using test credentials is a bad idea: first because this means the tests are not hermetic and reproducible, then because it hammers Twilio API endpoint every time a test is run, and last because it makes the test flaky by adding a dependency on internet connectivity and the endpoint being online.

To solve that, could you please provide a library that allows users to test the integration with the Client instance?

@tiwarishubham635
Copy link
Contributor

hi! have you tried using this example?

@tiwarishubham635 tiwarishubham635 added status: waiting for feedback waiting for feedback from the submitter status: waiting for feature feature will be implemented in the future priority: low Nice-to-have; can wait labels Apr 21, 2025
@qdii
Copy link
Author

qdii commented Apr 24, 2025

@tiwarishubham635 Yeah, I think this could be used to create such a fake client.

However to make it a viable solution, we'd need to know the details of the API calls made by the real client and api.twilio.com.

Also, I'm not sure how often this API changes, or if such changes are going to be backward-compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low Nice-to-have; can wait status: waiting for feature feature will be implemented in the future status: waiting for feedback waiting for feedback from the submitter
Projects
None yet
Development

No branches or pull requests

2 participants