예제 #1
0
    def test_unknown_command(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')

        # Act
        reply = _process_command('halp', ['halp'], mailbox, '+15555555555')

        # Assert
        self.assertIn('ANTI_VOICEMAIL_COMMANDS', reply)
예제 #2
0
    def test_disable(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Verizon Wireless')

        # Act
        reply = _process_command('disable', ['disable'], mailbox, '+15555555555')

        # Assert
        self.assertIn('*73', reply)
예제 #3
0
    def test_sms_whitelist_bad_number(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')

        # Act
        body = 'whitelist 415 777'
        reply = _process_command('whitelist', body.split(), mailbox, '+15555555555')

        # Assert
        self.assertEqual(mailbox.whitelist, set())
        self.assertIn('an you send it to me again?', reply)
예제 #4
0
    def test_sms_whitelist(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')

        # Act
        body = 'whitelist 415 777 7777'
        reply = _process_command('whitelist', body.split(), mailbox, '+15555555555')

        # Assert
        self.assertEqual(mailbox.whitelist, set(['+14157777777']))
        self.assertIn('always allow calls from (415) 777-7777', reply)
예제 #5
0
    def test_sms_reset_command(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')
        db.session.add(mailbox)

        mock_lookup_result = MagicMock()
        mock_lookup_result.carrier = {'name': 'Bar Wireless'}

        # Act
        with patch('app.models.look_up_number', return_value=mock_lookup_result):
            reply = _process_command('reset', ['reset'], mailbox, '+15555555555')

        # Assert
        self.assertIn('Bzzzzt!', reply)

        mailboxes = Mailbox.query.all()
        self.assertEqual(len(mailboxes), 1)
        self.assertEqual(mailboxes[0].carrier, 'Bar Wireless')