chore: import upstream snapshot with attribution
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from invokeai.backend.model_manager.configs.external_api import (
|
||||
ExternalApiModelConfig,
|
||||
ExternalApiModelDefaultSettings,
|
||||
ExternalImageSize,
|
||||
ExternalModelCapabilities,
|
||||
)
|
||||
|
||||
|
||||
def test_external_api_model_config_defaults() -> None:
|
||||
capabilities = ExternalModelCapabilities(modes=["txt2img"], supports_seed=True)
|
||||
|
||||
config = ExternalApiModelConfig(
|
||||
name="Test External",
|
||||
provider_id="openai",
|
||||
provider_model_id="gpt-image-1",
|
||||
capabilities=capabilities,
|
||||
)
|
||||
|
||||
assert config.path == "external://openai/gpt-image-1"
|
||||
assert config.source == "external://openai/gpt-image-1"
|
||||
assert config.hash == "external:openai:gpt-image-1"
|
||||
assert config.file_size == 0
|
||||
assert config.default_settings is None
|
||||
assert config.capabilities.supports_seed is True
|
||||
|
||||
|
||||
def test_external_api_model_capabilities_allows_aspect_ratio_sizes() -> None:
|
||||
capabilities = ExternalModelCapabilities(
|
||||
modes=["txt2img"],
|
||||
allowed_aspect_ratios=["1:1"],
|
||||
aspect_ratio_sizes={"1:1": ExternalImageSize(width=1024, height=1024)},
|
||||
)
|
||||
|
||||
assert capabilities.aspect_ratio_sizes is not None
|
||||
assert capabilities.aspect_ratio_sizes["1:1"].width == 1024
|
||||
|
||||
|
||||
def test_external_api_model_config_rejects_extra_fields() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ExternalModelCapabilities(modes=["txt2img"], supports_seed=True, extra_field=True) # type: ignore
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
ExternalApiModelDefaultSettings(width=512, extra_field=True) # type: ignore
|
||||
|
||||
|
||||
def test_external_api_model_config_validates_limits() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ExternalModelCapabilities(modes=["txt2img"], max_images_per_request=0)
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
ExternalApiModelDefaultSettings(width=0)
|
||||
Reference in New Issue
Block a user