Created
December 31, 2020 12:15
-
-
Save cfc603/1ae593b4e8a12051b318affb4a34253b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import vcr | |
| from django.conf import settings | |
| from django_twilio.settings import TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN | |
| from twilio.rest import Client | |
| twilio_vcr = vcr.VCR( | |
| cassette_library_dir="fixtures/cassettes", | |
| filter_headers=['authorization'], | |
| match_on=["uri"], | |
| record_mode="new_episodes", | |
| ) | |
| class MockClient(Client): | |
| @twilio_vcr.use_cassette() | |
| def request(self, *args, **kwargs): | |
| return super().request(*args, **kwargs) | |
| if settings.ENABLE_MOCK_CLIENT and settings.DEBUG: | |
| twilio_client = MockClient( | |
| TWILIO_ACCOUNT_SID, | |
| TWILIO_AUTH_TOKEN, | |
| ) | |
| else: | |
| twilio_client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment