Example #1
0
    def test_send_message(self, mock_client, mock_status_callback):
        mock_client.messages.create.return_value = self.mock_message()
        mock_status_callback.return_value = 'test'

        message, created = Message.send_message(body='test',
                                                to='+19999999992',
                                                from_='+19999999991')

        self.assertIsInstance(message, Message)
        self.assertTrue(mock_status_callback.called)
        mock_client.messages.create.assert_called_with(body='test',
                                                       to='+19999999992',
                                                       from_='+19999999991',
                                                       status_callback='test')
    def test_send_message(self, mock_client, mock_status_callback):
        mock_client.messages.create.return_value = self.mock_message()
        mock_status_callback.return_value = 'test'

        message, created = Message.send_message(
            body='test', to='+19999999992', from_='+19999999991'
        )

        self.assertIsInstance(message, Message)
        self.assertTrue(mock_status_callback.called)
        mock_client.messages.create.assert_called_with(
            body='test',
            to='+19999999992',
            from_='+19999999991',
            status_callback='test'
        )
 def test_get_or_create_if_message_sid_with_exception(self, twilio_message):
     twilio_message.return_value = self.mock_message()
     message, created = Message.get_or_create('test')
     self.assertTrue(created)
     self.assertEqual(message, Message.objects.first())
     self.assertEqual(1, Message.objects.all().count())
 def test_get_or_create_if_not_message_sid_with_exception(self):
     message, created = Message.get_or_create(message=self.mock_message())
     self.assertTrue(created)
     self.assertEqual(message, Message.objects.first())
     self.assertEqual(1, Message.objects.all().count())
 def test_get_or_create_if_message_sid_no_exception(self):
     message_1 = message_recipe.make(sid='test')
     message_2, created = Message.get_or_create(message_sid='test')
     self.assertFalse(created)
     self.assertEqual(message_1, message_2)
     self.assertEqual(1, Message.objects.all().count())
 def test_get_status_choice_status_display_not_equal_choice(self):
     self.assertEqual(None, Message.get_status_choice('test'))
 def test_get_status_choice_status_display_equal_choice(self):
     self.assertEqual(
         Message.ACCEPTED, Message.get_status_choice('accepted')
     )
 def test_get_direction_choice_direction_display_not_equal_choice(self):
     self.assertEqual(None, Message.get_direction_choice('test'))
Example #9
0
 def test_get_direction_choice_direction_display_not_equal_choice(self):
     self.assertEqual(None, Message.get_direction_choice('test'))
Example #10
0
 def test_get_status_callback(self):
     self.assertEqual(
         Message.get_status_callback(),
         'https://www.test.com/twilio-integration/webhooks/callback-view/')
Example #11
0
 def test_get_or_create_if_message_sid_with_exception(self, twilio_message):
     twilio_message.return_value = self.mock_message()
     message, created = Message.get_or_create('test')
     self.assertTrue(created)
     self.assertEqual(message, Message.objects.first())
     self.assertEqual(1, Message.objects.all().count())
Example #12
0
 def test_get_or_create_if_not_message_sid_with_exception(self):
     message, created = Message.get_or_create(message=self.mock_message())
     self.assertTrue(created)
     self.assertEqual(message, Message.objects.first())
     self.assertEqual(1, Message.objects.all().count())
Example #13
0
 def test_get_or_create_if_message_sid_no_exception(self):
     message_1 = message_recipe.make(sid='test')
     message_2, created = Message.get_or_create(message_sid='test')
     self.assertFalse(created)
     self.assertEqual(message_1, message_2)
     self.assertEqual(1, Message.objects.all().count())
Example #14
0
 def test_get_status_choice_status_display_not_equal_choice(self):
     self.assertEqual(None, Message.get_status_choice('test'))
Example #15
0
 def test_get_status_choice_status_display_equal_choice(self):
     self.assertEqual(Message.ACCEPTED,
                      Message.get_status_choice('accepted'))
 def test_get_direction_choice_direction_display_equal_choice(self):
     self.assertEqual(
         Message.INBOUND, Message.get_direction_choice('inbound')
     )
 def test_get_status_callback(self):
     self.assertEqual(
         Message.get_status_callback(),
         'https://www.test.com/twilio-integration/webhooks/callback-view/'
     )
Example #18
0
 def test_get_direction_choice_direction_display_equal_choice(self):
     self.assertEqual(Message.INBOUND,
                      Message.get_direction_choice('inbound'))