test: fix test failures and achieve 98% pass rate
Fix critical test failures preventing backend test suite from running: - tests/ui/test_menu.py: Fix 20+ IndentationErrors where 'with' blocks weren't properly indented. Also fix ui.menu.select_menu references to use imported select_menu function. - tests/integrations/graphiti/providers_pkg/embedder_providers/test_azure_openai_embedder.py: Fix config attribute name (azure_openai_base_url vs azure_openai_endpoint). Update test to handle success case since graphiti-core is installed. Add additional test cases for missing config validation. - tests/merge/test_auto_merger_context.py: Fix datetime overflow bug by using timedelta instead of manual minute arithmetic (minute + 5 could exceed 59). Results: 4,464 tests passing (98% pass rate), 87 remaining failures are pre-existing test infrastructure issues (stdin mocking, deprecated patterns).
This commit is contained in:
+55
-10
@@ -7,25 +7,26 @@ import pytest
|
||||
from integrations.graphiti.providers_pkg.embedder_providers.azure_openai_embedder import (
|
||||
create_azure_openai_embedder,
|
||||
)
|
||||
from integrations.graphiti.providers_pkg.exceptions import ProviderNotInstalled
|
||||
from integrations.graphiti.providers_pkg.exceptions import ProviderNotInstalled, ProviderError
|
||||
|
||||
|
||||
def test_create_azure_openai_embedder():
|
||||
"""Test create_azure_openai_embedder"""
|
||||
"""Test create_azure_openai_embedder successfully creates embedder"""
|
||||
|
||||
# Arrange
|
||||
config = MagicMock()
|
||||
config.azure_openai_api_key = "test-api-key"
|
||||
config.azure_openai_endpoint = "https://test.openai.azure.com"
|
||||
config.azure_openai_base_url = "https://test.openai.azure.com"
|
||||
config.azure_openai_embedding_deployment = "test-deployment"
|
||||
config.azure_openai_embedding_model = "text-embedding-ada-002"
|
||||
|
||||
# Act & Assert
|
||||
# The function requires graphiti-core which may not be installed
|
||||
# We test the error handling path
|
||||
with pytest.raises(ProviderNotInstalled) as exc_info:
|
||||
create_azure_openai_embedder(config)
|
||||
assert "graphiti-core" in str(exc_info.value)
|
||||
# Act
|
||||
result = create_azure_openai_embedder(config)
|
||||
|
||||
# Assert
|
||||
assert result is not None
|
||||
# Check that it's an AzureOpenAIEmbedderClient
|
||||
assert result.__class__.__name__ == "AzureOpenAIEmbedderClient"
|
||||
|
||||
|
||||
def test_create_azure_openai_embedder_missing_api_key():
|
||||
@@ -36,5 +37,49 @@ def test_create_azure_openai_embedder_missing_api_key():
|
||||
config.azure_openai_api_key = None
|
||||
|
||||
# Act & Assert
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(ProviderError, match="AZURE_OPENAI_API_KEY"):
|
||||
create_azure_openai_embedder(config)
|
||||
|
||||
|
||||
def test_create_azure_openai_embedder_missing_base_url():
|
||||
"""Test create_azure_openai_embedder raises error when base URL is missing"""
|
||||
|
||||
# Arrange
|
||||
config = MagicMock()
|
||||
config.azure_openai_api_key = "test-api-key"
|
||||
config.azure_openai_base_url = None
|
||||
|
||||
# Act & Assert
|
||||
with pytest.raises(ProviderError, match="AZURE_OPENAI_BASE_URL"):
|
||||
create_azure_openai_embedder(config)
|
||||
|
||||
|
||||
def test_create_azure_openai_embedder_missing_deployment():
|
||||
"""Test create_azure_openai_embedder raises error when deployment is missing"""
|
||||
|
||||
# Arrange
|
||||
config = MagicMock()
|
||||
config.azure_openai_api_key = "test-api-key"
|
||||
config.azure_openai_base_url = "https://test.openai.azure.com"
|
||||
config.azure_openai_embedding_deployment = None
|
||||
|
||||
# Act & Assert
|
||||
with pytest.raises(ProviderError, match="AZURE_OPENAI_EMBEDDING_DEPLOYMENT"):
|
||||
create_azure_openai_embedder(config)
|
||||
|
||||
|
||||
def test_create_azure_openai_embedder_without_graphiti_core():
|
||||
"""Test create_azure_openai_embedder raises ProviderNotInstalled when graphiti-core is missing"""
|
||||
|
||||
# Arrange
|
||||
config = MagicMock()
|
||||
config.azure_openai_api_key = "test-api-key"
|
||||
config.azure_openai_base_url = "https://test.openai.azure.com"
|
||||
config.azure_openai_embedding_deployment = "test-deployment"
|
||||
|
||||
# Act & Assert
|
||||
# Patch the import statement to simulate missing graphiti-core
|
||||
with patch("builtins.__import__", side_effect=ImportError("No module named 'graphiti_core'")):
|
||||
with pytest.raises(ProviderNotInstalled) as exc_info:
|
||||
create_azure_openai_embedder(config)
|
||||
assert "graphiti-core" in str(exc_info.value)
|
||||
|
||||
@@ -413,8 +413,9 @@ export default App;
|
||||
|
||||
def test_merge_context_with_completed_timestamp(self):
|
||||
"""Test MergeContext with snapshots that have completed_at timestamps"""
|
||||
from datetime import timedelta
|
||||
now = datetime.now()
|
||||
completed = datetime(now.year, now.month, now.day, now.hour, now.minute + 5)
|
||||
completed = now + timedelta(minutes=5)
|
||||
|
||||
snapshot = TaskSnapshot(
|
||||
task_id="task_001",
|
||||
|
||||
+311
-291
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user