コード例 #1
0
ファイル: test_notification.py プロジェクト: manasdas17/PIoT
    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')
コード例 #2
0
    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')
コード例 #3
0
    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'
コード例 #4
0
ファイル: fixtures.py プロジェクト: tnewman/PIoT
def sensormodule():
    sms_notification = TwilioSMSNotification()

    sensor_service = SensorReadingSchedulingService(sensor_class=MockSensor)
    sensor_service.sms_notification.send_notification = MagicMock()
    return sensor_service
コード例 #5
0
ファイル: testtwilio.py プロジェクト: tnewman/PIoT
#!/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':
コード例 #6
0
ファイル: testtwilio.py プロジェクト: manasdas17/PIoT
#!/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':