Ejemplo n.º 1
0
    def test_import_config_diff_number(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')
        db.session.add(mailbox)
        db.session.commit()

        # Act
        with patch('app.setup.views.Mailbox.import_config_image') as mock:
            from werkzeug.exceptions import Forbidden
            with self.assertRaises(Forbidden):
                _import_config('+17777777777', 'http://i.imgur.com/VMSuO1N.gif')

        # Assert
        self.assertFalse(mock.called)
Ejemplo n.º 2
0
    def test_import_config_no_mailbox(self):
        # Act
        with patch('app.setup.views.Mailbox.import_config_image', return_value='Imported!') as mock:
            result = _import_config('+15555555555', 'http://i.imgur.com/VMSuO1N.gif')

        # Assert
        self.assertEqual(result, 'Imported!')
        mock.assert_called_once_with('http://i.imgur.com/VMSuO1N.gif')
Ejemplo n.º 3
0
    def test_import_config_same_number(self):
        # Arrange
        mailbox = Mailbox(phone_number='+15555555555', carrier='Foo Wireless')
        db.session.add(mailbox)
        db.session.commit()

        # Act
        with patch('app.setup.views.Mailbox.import_config_image', return_value='Imported!') as mock:
            result = _import_config('+15555555555', 'http://i.imgur.com/VMSuO1N.gif')

        # Assert
        self.assertEqual(result, 'Imported!')
        mock.assert_called_once_with('http://i.imgur.com/VMSuO1N.gif')