OpenAI-compatible adapter for ComfyUI image generation and editing
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from app.config import DEFAULT_MAPPING, Settings
|
||||
|
||||
|
||||
def test_defaults():
|
||||
s = Settings(_env_file=None)
|
||||
assert s.comfy_base_url == "http://192.168.0.3:8188"
|
||||
assert s.execution_timeout == 300.0
|
||||
assert s.poll_interval == 1.5
|
||||
assert s.mapping() == DEFAULT_MAPPING
|
||||
|
||||
|
||||
def test_env_override(monkeypatch):
|
||||
monkeypatch.setenv("COMFY_BASE_URL", "http://example:9000")
|
||||
monkeypatch.setenv("ADAPTER_API_KEY", "sk-abc")
|
||||
monkeypatch.setenv("EXECUTION_TIMEOUT", "42")
|
||||
monkeypatch.setenv("POLL_INTERVAL", "0.5")
|
||||
s = Settings(_env_file=None)
|
||||
assert s.comfy_base_url == "http://example:9000"
|
||||
assert s.adapter_api_key == "sk-abc"
|
||||
assert s.execution_timeout == 42.0
|
||||
assert s.poll_interval == 0.5
|
||||
|
||||
|
||||
def test_mapping_file_override(tmp_path):
|
||||
f = tmp_path / "mapping.json"
|
||||
f.write_text('{"create": {"prompt": {"node": "1", "field": "t"}}}', encoding="utf-8")
|
||||
s = Settings(_env_file=None, mapping_file=f)
|
||||
m = s.mapping()
|
||||
assert m["create"]["prompt"] == {"node": "1", "field": "t"}
|
||||
# other sections/keys keep defaults
|
||||
assert m["edit"] == DEFAULT_MAPPING["edit"]
|
||||
assert m["create"]["seed"] == DEFAULT_MAPPING["create"]["seed"]
|
||||
Reference in New Issue
Block a user