from app.core.llm.llm_service import ( fallback_translate_chinese, is_valid_translation, normalize_translation_text, translate_chinese_identifier, ) def test_normalize_translation_text_strips_chinese(): assert normalize_translation_text("测试宁波数据加工") == "" assert normalize_translation_text('"Ningbo Data Processing"') == "ningbo_data_processing" def test_fallback_translate_ningbo_data_processing(): result = fallback_translate_chinese("测试宁波数据加工") assert result == "ningbo_data_processing_test" assert is_valid_translation(result) def test_translate_chinese_identifier_uses_fallback_when_llm_unavailable(monkeypatch): def _raise(*args, **kwargs): raise ValueError("DeepSeek API Key 未配置") monkeypatch.setattr( "app.core.llm.llm_service.create_llm_client", _raise, ) result = translate_chinese_identifier("测试宁波数据加工") assert result == "ningbo_data_processing_test"