Ejemplo n.º 1
0
    def test_user_deactivate_wrong_user(self, mock_g, mock_login):
        """Test deactivating user from different user id."""
        from mod_auth.controllers import deactivate

        mock_g.user = MockUser(id=1, role="None")

        with self.assertRaises(Forbidden):
            deactivate(2)
Ejemplo n.º 2
0
    def test_user_deactivate_non_existent_user(self, mock_g, mock_login,
                                               mock_user):
        """Test deactivating user from non-existent user id."""
        from mod_auth.controllers import deactivate

        mock_g.user = MockUser(id=1, role="None")
        mock_user.query.filter_by.return_value.first.return_value = None

        with self.assertRaises(NotFound):
            deactivate(1)
Ejemplo n.º 3
0
    def test_user_deactivate_existent_user(self, mock_g, mock_login, mock_user,
                                           mock_form, mock_url_for):
        """Test deactivating user."""
        from mod_auth.controllers import deactivate

        mock_user.query.filter_by.return_value.first.return_value = MockUser(
            id=1, role=None)
        mock_g.user = MockUser(id=1, role="None")

        deactivate(1)

        mock_user.query.filter_by.assert_called_once_with(id=1)
        mock_form.assert_called_once()
        mock_form.return_value.validate_on_submit.assert_called_once()
        mock_g.db.commit.assert_called_once()
        mock_url_for.assert_called_once_with('.login')