Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Add tests for type_utils module

LearningCircuitec39a580d680
diff --git a/tests/utilities/test_type_utils.py b/tests/utilities/test_type_utils.py
new file mode 100644
index 0000000000..811cedf620
--- /dev/null
+++ b/tests/utilities/test_type_utils.py
@@ -0,0 +1,187 @@
+"""
+Tests for utilities/type_utils.py
+
+Tests cover:
+- to_bool function with various input types
+- String representations
+- Default values
+- Edge cases
+"""
+
+
+class TestToBool:
+ """Tests for to_bool function."""
+
+ def test_bool_true_passthrough(self):
+ """Test that True passes through unchanged."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(True) is True
+
+ def test_bool_false_passthrough(self):
+ """Test that False passes through unchanged."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(False) is False
+
+ def test_string_true(self):
+ """Test string 'true' converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("true") is True
+
+ def test_string_false(self):
+ """Test string 'false' converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("false") is False
+
+ def test_string_yes(self):
+ """Test string 'yes' converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("yes") is True
+
+ def test_string_no(self):
+ """Test string 'no' converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("no") is False
+
+ def test_string_one(self):
+ """Test string '1' converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("1") is True
+
+ def test_string_zero(self):
+ """Test string '0' converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("0") is False
+
+ def test_string_on(self):
+ """Test string 'on' converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("on") is True
+
+ def test_string_off(self):
+ """Test string 'off' converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("off") is False
+
+ def test_string_enabled(self):
+ """Test string 'enabled' converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("enabled") is True
+
+ def test_string_disabled(self):
+ """Test string 'disabled' converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("disabled") is False
+
+ def test_string_case_insensitive(self):
+ """Test string conversion is case insensitive."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("TRUE") is True
+ assert to_bool("True") is True
+ assert to_bool("YES") is True
+ assert to_bool("Yes") is True
+
+ def test_integer_one(self):
+ """Test integer 1 converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(1) is True
+
+ def test_integer_zero(self):
+ """Test integer 0 converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(0) is False
+
+ def test_integer_positive(self):
+ """Test positive integers convert to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(5) is True
+ assert to_bool(100) is True
+
+ def test_integer_negative(self):
+ """Test negative integers convert to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(-1) is True
+
+ def test_none_uses_default_false(self):
+ """Test None uses default False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(None) is False
+
+ def test_none_uses_default_true(self):
+ """Test None uses custom default True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(None, default=True) is True
+
+ def test_empty_string(self):
+ """Test empty string converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("") is False
+
+ def test_whitespace_string(self):
+ """Test whitespace string converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(" ") is False
+
+ def test_arbitrary_string(self):
+ """Test arbitrary string converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool("random") is False
+ assert to_bool("anything") is False
+
+ def test_float_zero(self):
+ """Test float 0.0 converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(0.0) is False
+
+ def test_float_nonzero(self):
+ """Test non-zero float converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool(1.0) is True
+ assert to_bool(0.5) is True
+
+ def test_empty_list(self):
+ """Test empty list converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool([]) is False
+
+ def test_non_empty_list(self):
+ """Test non-empty list converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool([1, 2, 3]) is True
+
+ def test_empty_dict(self):
+ """Test empty dict converts to False."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool({}) is False
+
+ def test_non_empty_dict(self):
+ """Test non-empty dict converts to True."""
+ from local_deep_research.utilities.type_utils import to_bool
+
+ assert to_bool({"key": "value"}) is True