Skip to content

Instantly share code, notes, and snippets.

@aezell
Created August 29, 2012 19:58
Show Gist options
  • Save aezell/3518040 to your computer and use it in GitHub Desktop.
Save aezell/3518040 to your computer and use it in GitHub Desktop.
Mock Twilio
@patch('twilio.rest.resources.SmsMessages')
def test_send_sms_valid_args(self, MockClass):
instance = MockClass.return_value
instance.create.return_value = None
to_number = 5555555555
msg = 'Hello world'
send_sms(to_number, msg)
instance.create.assert_called_once_with(to='+1' + str(to_number),
body=msg, from_=settings.TWILIO_FROM_NUM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment