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

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

        with self.assertRaises(Forbidden):
            user(2)
Ejemplo n.º 2
0
    def test_user_view_non_existent_user(self, mock_user, mock_g, mock_login):
        """Test accessing for user not existent."""
        from mod_auth.controllers import user

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

        with self.assertRaises(NotFound):
            user(1)

        mock_user.query.filter_by.assert_called_once_with(id=1)