def test_send_notification(self): config.twilio_account = 'account' config.twilio_token = 'token' config.twilio_sender_number = 'send' config.twilio_recipient_number = 'receive' twilio = TwilioSMSNotification() twilio.twilio_client.messages.create = MagicMock() twilio.send_notification('test message') twilio.twilio_client.messages.create.assert_called_with( body='test message', to='receive', from_='send')
def test_twilio_account_and_token_set(self): config.twilio_account = 'account' config.twilio_token = 'token' twilio = TwilioSMSNotification() assert twilio.twilio_client.auth[0] == 'account' assert twilio.twilio_client.auth[1] == 'token'
def sensormodule(): sms_notification = TwilioSMSNotification() sensor_service = SensorReadingSchedulingService(sensor_class=MockSensor) sensor_service.sms_notification.send_notification = MagicMock() return sensor_service
#!/usr/bin/env python3 import os import sys os.chdir('..') sys.path.append('.') from piot.notification import TwilioSMSNotification from twilio import TwilioRestException print('==================') print('Twilio Test Script') print('==================') while True: twilio_notification = TwilioSMSNotification() try: twilio_notification.send_notification('Test Notification from PIoT') except TwilioRestException: print('Twilio Exception - Check Connectivity and Settings') print('Test Failed') exit(1) print('SMS Send') print('Did you receieve an SMS [Yes/No]') result = input() if result.lower() == 'yes': print('Test Passed') exit(0) elif result.lower() == 'no':
#!/usr/bin/env python3 import os import sys os.chdir('..') sys.path.append('.') from piot.notification import TwilioSMSNotification from twilio import TwilioRestException print('==================') print('Twilio Test Script') print('==================') while True: twilio_notification=TwilioSMSNotification() try: twilio_notification.send_notification('Test Notification from PIoT') except TwilioRestException: print('Twilio Exception - Check Connectivity and Settings') print('Test Failed') exit(1) print('SMS Send') print('Did you receieve an SMS [Yes/No]') result=input() if result.lower()=='yes': print('Test Passed') exit(0) elif result.lower()=='no':