Files
darth-veitcher bb9ede6da9 feat: flexible model input with manual entry and connected JSON support
- Refactored all nodes to accept both manual string input and connected models_json
- Removed rigid enum-based dropdowns in favor of flexible STRING inputs
- Added optional models_json input to Select, Load, and Unload nodes
- Nodes now parse JSON and update cache when models_json is connected
- Supports Ollama's auto-pull behavior for models not yet downloaded
- Updated category from "Ollama/Enum" to "Ollama" for cleaner UI organization

Benefits:
- No UI refresh required for manual model entry
- Automatic model pulling when typing new model names
- Still supports connected workflow pattern (Refresh → Select → Load)
- Maximum flexibility - users choose their preferred workflow

Test updates:
- Fixed all tests for new flexible input signatures
- Added comprehensive warning filters for pytest mock internals
- All 28 tests passing with 0 warnings

Documentation:
- Updated README with both usage patterns (connected and manual)
- Added example workflows for different use cases
- Clarified benefits of each approach
2025-11-01 10:40:48 +00:00

38 lines
1.0 KiB
Python

"""Tests for state management module."""
from comfyui_ollama_model_manager.state import get_endpoint, get_models, set_models
def test_initial_state():
"""Test the initial state of the model cache."""
endpoint = get_endpoint()
assert endpoint == "http://localhost:11434"
def test_set_and_get_models(mock_endpoint, sample_models):
"""Test setting and getting models from cache."""
set_models(mock_endpoint, sample_models)
assert get_endpoint() == mock_endpoint
assert get_models() == sample_models
def test_get_models_returns_copy(mock_endpoint, sample_models):
"""Ensure get_models returns a copy, not the original list."""
set_models(mock_endpoint, sample_models)
models1 = get_models()
models2 = get_models()
# Should be equal but not the same object
assert models1 == models2
assert models1 is not models2
def test_empty_models_list(mock_endpoint):
"""Test setting an empty models list."""
set_models(mock_endpoint, [])
assert get_models() == []
assert get_endpoint() == mock_endpoint