diff --git a/requirements.txt b/requirements.txt index b8bdc7dcc..7be82a074 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ mccabe==0.6.1 pycodestyle==2.6.0 pyflakes==2.2.0 yapf==0.30.0 +twilio==7.3.2 diff --git a/tools/snippet-testing/language_handler/python.rb b/tools/snippet-testing/language_handler/python.rb index d4d652312..35cdc3e97 100644 --- a/tools/snippet-testing/language_handler/python.rb +++ b/tools/snippet-testing/language_handler/python.rb @@ -16,7 +16,20 @@ def self.run_before_test(directory) end private - + def text_with_custom_header(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.prepend( + "import twilio.rest.resources.base\n"\ + "import sys\n"\ + "twilio.rest.resources.base.get_cert_file = lambda: '#{cert_path}'\n"\ + "sys.modules['twilio.rest.base.resources'] = twilio.rest.resources.base\n" + ) + end + def replace_twilio_client_initialization(file_content) + cert_path = ENV['FAKE_CERT_PATH'] + file_content.gsub! 'Client(account_sid, auth_token)', + 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content + end def execute_command(file) command = bash_string_command( 'source /usr/local/bin/virtualenvwrapper.sh &&'\