Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
"""Process tool policy: None defers to the request, True forces tools on, False forces them off."""
import os
import sys
_backend = os.path.join(os.path.dirname(__file__), "..")
sys.path.insert(0, _backend)
import pytest
from state.tool_policy import (
get_tool_policy,
reset_tool_policy,
set_tool_policy,
)
@pytest.fixture(autouse = True)
def _reset():
reset_tool_policy()
yield
reset_tool_policy()
class TestToolPolicy:
def test_default_is_none(self):
assert get_tool_policy() is None
def test_set_true_then_get(self):
set_tool_policy(True)
assert get_tool_policy() is True
def test_set_false_then_get(self):
set_tool_policy(False)
assert get_tool_policy() is False
def test_set_none_clears(self):
set_tool_policy(True)
set_tool_policy(None)
assert get_tool_policy() is None
def test_reset_clears(self):
set_tool_policy(False)
reset_tool_policy()
assert get_tool_policy() is None
def test_rejects_non_optional_bool(self):
with pytest.raises(TypeError):
set_tool_policy("true") # type: ignore[arg-type]