From f2a1847557ac2f7fc4b912e4fdf9b4600e931ccc Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Mon, 23 Mar 2026 23:01:20 +0800 Subject: [PATCH] test(15-01): add failing test for enable_semantic_segmentation field - Test KBSettings has enable_semantic_segmentation field with bool type - Test default value is True - Test environment variable override (KB_ENABLE_SEMANTIC_SEGMENTATION) - Test boolean string parsing (true/false, yes/no, 1/0) Co-Authored-By: Claude Opus 4.6 --- tests/test_pipeline/test_config.py | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/test_pipeline/test_config.py b/tests/test_pipeline/test_config.py index 35c3e19..83edd6b 100644 --- a/tests/test_pipeline/test_config.py +++ b/tests/test_pipeline/test_config.py @@ -148,3 +148,69 @@ class TestKBSettingsEnvFile: def test_kbsettings_model_config_ignores_extra(self): """Test KBSettings model_config ignores extra fields""" assert KBSettings.model_config.get("extra") == "ignore" + + +class TestEnableSemanticSegmentationField: + """Tests for enable_semantic_segmentation field (CONFIG-01)""" + + def test_kbsettings_has_enable_semantic_segmentation_field(self): + """Test KBSettings has enable_semantic_segmentation field""" + settings = KBSettings( + base_path="/tmp/kb", + archive_path="/tmp/archive" + ) + assert hasattr(settings, "enable_semantic_segmentation"), \ + "KBSettings should have enable_semantic_segmentation field" + assert isinstance(settings.enable_semantic_segmentation, bool), \ + "enable_semantic_segmentation should be bool type" + + def test_enable_semantic_segmentation_default_value(self): + """Test default value is True""" + with patch.dict(os.environ, {}, clear=True): + settings = KBSettings( + base_path="/tmp/kb", + archive_path="/tmp/archive", + _env_file=None + ) + assert settings.enable_semantic_segmentation is True, \ + "enable_semantic_segmentation should default to True" + + def test_enable_semantic_segmentation_from_env(self): + """Test KB_ENABLE_SEMANTIC_SEGMENTATION env var is respected""" + with patch.dict(os.environ, { + "KB_ENABLE_SEMANTIC_SEGMENTATION": "false" + }, clear=False): + get_settings.cache_clear() + settings = KBSettings( + base_path="/tmp/kb", + archive_path="/tmp/archive" + ) + assert settings.enable_semantic_segmentation is False, \ + "enable_semantic_segmentation should be False when env var is 'false'" + + def test_enable_semantic_segmentation_boolean_parsing(self): + """Test boolean string parsing (true/false, yes/no, 1/0)""" + test_cases = [ + ("true", True), + ("True", True), + ("TRUE", True), + ("yes", True), + ("1", True), + ("false", False), + ("False", False), + ("FALSE", False), + ("no", False), + ("0", False), + ] + + for env_value, expected in test_cases: + with patch.dict(os.environ, { + "KB_ENABLE_SEMANTIC_SEGMENTATION": env_value + }, clear=False): + get_settings.cache_clear() + settings = KBSettings( + base_path="/tmp/kb", + archive_path="/tmp/archive" + ) + assert settings.enable_semantic_segmentation is expected, \ + f"Failed for env_value={env_value}, expected={expected}"