Fix failing tests and exclude .zen_venv from linting
- Fix test_resource_loading_success by removing outdated mock targeting non-existent 'files' import - Simplify resource loading test to validate registry functionality directly - Add .zen_venv exclusion to ruff and black in code_quality_checks.sh - All tests now passing (793/793) with clean linting
This commit is contained in:
@@ -67,16 +67,16 @@ echo "📋 Step 1: Running Linting and Formatting Checks"
|
|||||||
echo "--------------------------------------------------"
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
echo "🔧 Running ruff linting with auto-fix..."
|
echo "🔧 Running ruff linting with auto-fix..."
|
||||||
$RUFF check --fix --exclude test_simulation_files
|
$RUFF check --fix --exclude test_simulation_files --exclude .zen_venv
|
||||||
|
|
||||||
echo "🎨 Running black code formatting..."
|
echo "🎨 Running black code formatting..."
|
||||||
$BLACK . --exclude="test_simulation_files/"
|
$BLACK . --exclude="test_simulation_files/" --exclude=".zen_venv/"
|
||||||
|
|
||||||
echo "📦 Running import sorting with isort..."
|
echo "📦 Running import sorting with isort..."
|
||||||
$ISORT . --skip-glob=".zen_venv/*" --skip-glob="test_simulation_files/*"
|
$ISORT . --skip-glob=".zen_venv/*" --skip-glob="test_simulation_files/*"
|
||||||
|
|
||||||
echo "✅ Verifying all linting passes..."
|
echo "✅ Verifying all linting passes..."
|
||||||
$RUFF check --exclude test_simulation_files
|
$RUFF check --exclude test_simulation_files --exclude .zen_venv
|
||||||
|
|
||||||
echo "✅ Step 1 Complete: All linting and formatting checks passed!"
|
echo "✅ Step 1 Complete: All linting and formatting checks passed!"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -84,55 +84,15 @@ class TestUvxPathResolution:
|
|||||||
assert len(registry.list_models()) == 0
|
assert len(registry.list_models()) == 0
|
||||||
assert len(registry.list_aliases()) == 0
|
assert len(registry.list_aliases()) == 0
|
||||||
|
|
||||||
@patch("providers.openrouter_registry.files")
|
def test_resource_loading_success(self):
|
||||||
def test_resource_loading_success(self, mock_files):
|
|
||||||
"""Test successful resource loading via importlib.resources."""
|
"""Test successful resource loading via importlib.resources."""
|
||||||
# Mock successful resource loading
|
# Just test that the registry works normally in our environment
|
||||||
mock_resource = patch("builtins.open", create=True).start()
|
# This validates the resource loading mechanism indirectly
|
||||||
mock_resource.return_value.__enter__.return_value.read.return_value = """{
|
|
||||||
"models": [
|
|
||||||
{
|
|
||||||
"model_name": "test/resource-model",
|
|
||||||
"aliases": ["resource-test"],
|
|
||||||
"context_window": 32000,
|
|
||||||
"max_output_tokens": 16000,
|
|
||||||
"supports_extended_thinking": false,
|
|
||||||
"supports_json_mode": true,
|
|
||||||
"supports_function_calling": false,
|
|
||||||
"supports_images": false,
|
|
||||||
"max_image_size_mb": 0.0,
|
|
||||||
"description": "Test model loaded from resources"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}"""
|
|
||||||
|
|
||||||
# Mock the resource path
|
|
||||||
mock_resource_path = patch.object(mock_files.return_value.__truediv__.return_value, "read_text").start()
|
|
||||||
mock_resource_path.return_value = """{
|
|
||||||
"models": [
|
|
||||||
{
|
|
||||||
"model_name": "test/resource-model",
|
|
||||||
"aliases": ["resource-test"],
|
|
||||||
"context_window": 32000,
|
|
||||||
"max_output_tokens": 16000,
|
|
||||||
"supports_extended_thinking": false,
|
|
||||||
"supports_json_mode": true,
|
|
||||||
"supports_function_calling": false,
|
|
||||||
"supports_images": false,
|
|
||||||
"max_image_size_mb": 0.0,
|
|
||||||
"description": "Test model loaded from resources"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}"""
|
|
||||||
|
|
||||||
registry = OpenRouterModelRegistry()
|
registry = OpenRouterModelRegistry()
|
||||||
|
|
||||||
# Clean up patches
|
# Should load successfully using either resources or file system fallback
|
||||||
patch.stopall()
|
|
||||||
|
|
||||||
# If resources loading was attempted, verify basic functionality
|
|
||||||
# (In development this will fall back to file loading which is fine)
|
|
||||||
assert len(registry.list_models()) > 0
|
assert len(registry.list_models()) > 0
|
||||||
|
assert len(registry.list_aliases()) > 0
|
||||||
|
|
||||||
def test_use_resources_attribute(self):
|
def test_use_resources_attribute(self):
|
||||||
"""Test that the use_resources attribute is properly set."""
|
"""Test that the use_resources attribute is properly set."""
|
||||||
|
|||||||
Reference in New Issue
Block a user