Exemple #1
0
    def test_send(self):
        driver = bulksms_driver.BulkSMSMessaging()
        driver.client = mock.Mock()

        msisdn = "12345678"
        user = utils.get_test_user(messaging_driver="sms", messaging_address=msisdn)
        info = utils.get_test_notification_info()

        driver.send(user, info)

        driver.client.send_sms.assert_called_with(recipients=[msisdn], sender="testsender", text=str(info))
Exemple #2
0
    def test_send(self):
        driver = clickatell_driver.ClickatellMessaging()
        driver.client = mock.Mock()

        msisdn = '12345678'
        user = utils.get_test_user(messaging_driver='sms',
                                   messaging_address=msisdn)
        info = utils.get_test_notification_info()

        driver.send(user, info)

        driver.client.sendmsg.assert_called_with(recipients=[msisdn],
                                                 sender='testsender',
                                                 text=str(info))
Exemple #3
0
    def test_send(self):
        user = utils.get_test_user()
        info = {'service': 'service_id',
                'state': 'normal',
                'previous_state': 'unexpected high'}

        with mock.patch('surveilr.messaging._get_driver') as _get_driver:
            messaging.send(user, info)

            # Check that _get_driver gets called with the user as its argument
            _get_driver.assert_called_with(user)

            # Check that _get_driver's return value (i.e. the driver)
            # gets its .send() method called with user and info as its
            # arguments
            _get_driver.return_value.send.assert_called_with(user, info)
Exemple #4
0
    def test_get_driver_default(self):
        user = utils.get_test_user()
        expected_driver = drivers.get_driver('messaging', 'fake')

        actual_driver = messaging._get_driver(user)
        self.assertEquals(actual_driver, expected_driver)
Exemple #5
0
 def test_send(self):
     user = utils.get_test_user()
     info = {'service': 'service_id',
             'state': 'normal',
             'previous_state': 'unexpected high'}
     self.driver.send(user, info)
Exemple #6
0
    def test_get_driver_sms(self):
        user = utils.get_test_user(messaging_driver='sms')
        expected_driver = drivers.get_driver('messaging', 'sms')

        actual_driver = messaging._get_driver(user)
        self.assertEquals(actual_driver, expected_driver)