Spaces:
Running on Zero
Running on Zero
test: update _on_model_change asserts for new 3-tuple return shape
Browse files- tests/test_app.py +17 -3
tests/test_app.py
CHANGED
|
@@ -2,15 +2,29 @@ import app
|
|
| 2 |
|
| 3 |
|
| 4 |
def test_on_model_change_returns_base_defaults():
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def test_on_model_change_returns_turbo_defaults():
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def test_on_model_change_unknown_falls_back_to_turbo():
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def test_preview_cn_returns_none_when_no_image():
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
def test_on_model_change_returns_base_defaults():
|
| 5 |
+
steps, cfg, _lora_update = app._on_model_change("Base")
|
| 6 |
+
assert (steps, cfg) == (25, 4.0)
|
| 7 |
|
| 8 |
|
| 9 |
def test_on_model_change_returns_turbo_defaults():
|
| 10 |
+
steps, cfg, _lora_update = app._on_model_change("Turbo")
|
| 11 |
+
assert (steps, cfg) == (8, 1.0)
|
| 12 |
|
| 13 |
|
| 14 |
def test_on_model_change_unknown_falls_back_to_turbo():
|
| 15 |
+
steps, cfg, _lora_update = app._on_model_change("Edit")
|
| 16 |
+
assert (steps, cfg) == (8, 1.0)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def test_on_model_change_emits_lora_label_hinting_model_compat():
|
| 20 |
+
"""Third element is a gr.update on the LoRA toggle whose label names the model."""
|
| 21 |
+
*_, base_update = app._on_model_change("Base")
|
| 22 |
+
*_, turbo_update = app._on_model_change("Turbo")
|
| 23 |
+
# gr.update returns a dict-like with the keyword args; both styles seen in Gradio 5.
|
| 24 |
+
base_label = getattr(base_update, "get", lambda *_: None)("label") or getattr(base_update, "label", None)
|
| 25 |
+
turbo_label = getattr(turbo_update, "get", lambda *_: None)("label") or getattr(turbo_update, "label", None)
|
| 26 |
+
assert base_label and "Z-Image" in base_label and "Turbo" not in base_label
|
| 27 |
+
assert turbo_label and "Z-Image-Turbo" in turbo_label
|
| 28 |
|
| 29 |
|
| 30 |
def test_preview_cn_returns_none_when_no_image():
|