MCPcopy Create free account
hub / github.com/AsyncFuncAI/deepwiki-open / TestEmbedderConfiguration

Class TestEmbedderConfiguration

tests/unit/test_all_embedders.py:84–143  ·  view source on GitHub ↗

Test embedder configuration system.

Source from the content-addressed store, hash-verified

82 return self.tests_failed == 0
83
84class TestEmbedderConfiguration:
85 """Test embedder configuration system."""
86
87 def test_config_loading(self):
88 """Test that all embedder configurations load properly."""
89 from api.config import configs, CLIENT_CLASSES
90
91 # Check all embedder configurations exist
92 assert 'embedder' in configs, "OpenAI embedder config missing"
93 assert 'embedder_google' in configs, "Google embedder config missing"
94 assert 'embedder_ollama' in configs, "Ollama embedder config missing"
95 assert 'embedder_bedrock' in configs, "Bedrock embedder config missing"
96
97 # Check client classes are available
98 assert 'OpenAIClient' in CLIENT_CLASSES, "OpenAIClient missing from CLIENT_CLASSES"
99 assert 'GoogleEmbedderClient' in CLIENT_CLASSES, "GoogleEmbedderClient missing from CLIENT_CLASSES"
100 assert 'OllamaClient' in CLIENT_CLASSES, "OllamaClient missing from CLIENT_CLASSES"
101 assert 'BedrockClient' in CLIENT_CLASSES, "BedrockClient missing from CLIENT_CLASSES"
102
103 def test_embedder_type_detection(self):
104 """Test embedder type detection functions."""
105 from api.config import get_embedder_type, is_ollama_embedder, is_google_embedder, is_bedrock_embedder
106
107 # Default type should be detected
108 current_type = get_embedder_type()
109 assert current_type in ['openai', 'google', 'ollama', 'bedrock'], f"Invalid embedder type: {current_type}"
110
111 # Boolean functions should work
112 is_ollama = is_ollama_embedder()
113 is_google = is_google_embedder()
114 is_bedrock = is_bedrock_embedder()
115 assert isinstance(is_ollama, bool), "is_ollama_embedder should return boolean"
116 assert isinstance(is_google, bool), "is_google_embedder should return boolean"
117 assert isinstance(is_bedrock, bool), "is_bedrock_embedder should return boolean"
118
119 # Only one should be true at a time (unless using openai default)
120 if current_type == 'bedrock':
121 assert is_bedrock and not is_ollama and not is_google
122 elif current_type == 'ollama':
123 assert is_ollama and not is_google and not is_bedrock
124 elif current_type == 'google':
125 assert is_google and not is_ollama and not is_bedrock
126 else: # openai
127 assert not is_ollama and not is_google and not is_bedrock
128
129 def test_get_embedder_config(self, embedder_type=None):
130 """Test getting embedder config for each type."""
131 from api.config import get_embedder_config
132
133 if embedder_type:
134 # Mock the EMBEDDER_TYPE for testing
135 with patch('api.config.EMBEDDER_TYPE', embedder_type):
136 config = get_embedder_config()
137 assert isinstance(config, dict), f"Config for {embedder_type} should be dict"
138 assert 'model_client' in config or 'client_class' in config, f"No client specified for {embedder_type}"
139 else:
140 # Test current configuration
141 config = get_embedder_config()

Callers 1

run_all_testsFunction · 0.85

Calls

no outgoing calls

Tested by 1

run_all_testsFunction · 0.68