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.

test: replace 3 tautology asserts in test_domain_classifier with real checks (#4248)

LearningCircuit6f7cf0562b63
diff --git a/tests/domain_classifier/test_domain_classifier.py b/tests/domain_classifier/test_domain_classifier.py
index fdea2cf8f2..f30b7340b0 100644
--- a/tests/domain_classifier/test_domain_classifier.py
+++ b/tests/domain_classifier/test_domain_classifier.py
@@ -228,11 +228,12 @@ class TestDomainClassifierClassify:
mock_session.query.return_value.filter_by.return_value.first.return_value = None
mock_get_db_session.return_value = mock_session
- # Should handle gracefully (returns None on error)
+ # Invalid JSON from the LLM raises ValueError inside the session
+ # context, which the SUT's broad `except Exception` catches and
+ # converts to a None return. (See classifier.py:225-265.)
result = classifier.classify_domain("example.com")
- # Should return some result even with invalid JSON
- assert result is not None or result is None # Either way is acceptable
+ assert result is None
@patch(
"local_deep_research.domain_classifier.classifier.get_user_db_session"
@@ -266,31 +267,35 @@ class TestDomainClassifierClassify:
def test_classify_domain_empty_domain(
self, mock_get_db_session, classifier
):
- """Test handling of empty domain."""
+ """Empty-string domain must not crash; the SUT routes through the
+ LLM path (no cached row), and with no LLM mock configured the
+ broad except in classify_domain converts the error to a None
+ return."""
mock_session = MagicMock()
mock_session.__enter__ = Mock(return_value=mock_session)
mock_session.__exit__ = Mock(return_value=False)
+ mock_session.query.return_value.filter_by.return_value.first.return_value = None
mock_get_db_session.return_value = mock_session
result = classifier.classify_domain("")
- # Should handle empty domain
- assert result is None or result is not None # Either is acceptable
+ assert result is None
@patch(
"local_deep_research.domain_classifier.classifier.get_user_db_session"
)
def test_classify_domain_none_domain(self, mock_get_db_session, classifier):
- """Test handling of None domain."""
+ """Same path as the empty-string case: no cached row, no LLM mock,
+ broad except → None return."""
mock_session = MagicMock()
mock_session.__enter__ = Mock(return_value=mock_session)
mock_session.__exit__ = Mock(return_value=False)
+ mock_session.query.return_value.filter_by.return_value.first.return_value = None
mock_get_db_session.return_value = mock_session
result = classifier.classify_domain(None)
- # Should handle None domain
- assert result is None or result is not None
+ assert result is None
class TestDomainClassificationModel: