Spaces:
Running on Zero
Running on Zero
File size: 3,352 Bytes
14b904e a7d0a44 14b904e af844a1 14b904e af844a1 14b904e af844a1 14b904e af844a1 14b904e af844a1 14b904e af844a1 14b904e 7953225 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | import gradio as gr
import pytest
import ui
@pytest.fixture(autouse=True)
def _blocks_ctx():
"""Each builder must be called inside a gr.Blocks() context."""
with gr.Blocks():
yield
def test_model_soon_row_links_to_zoo_twice():
html = ui._model_soon_row_html()
assert html.count(ui.MODEL_ZOO_URL) == 2
assert "Edit" in html and "Omni Base" in html
assert "(coming soon)" in html
assert 'target="_blank"' in html
assert 'rel="noopener noreferrer"' in html
def test_model_soon_row_uses_dim_link_class():
html = ui._model_soon_row_html()
assert 'class="zis-soon-row"' in html
def test_build_t2i_tab_returns_components():
components = ui.build_t2i_tab()
expected = {
"prompt",
"negative_prompt",
"model",
"base_group",
"lora_enabled",
"lora_group",
"steps",
"cfg",
"width",
"height",
"seed",
"lora_path",
"lora_strength",
"generate_btn",
"output_image",
"output_meta",
}
assert expected.issubset(components.keys())
def test_build_t2i_tab_model_is_native_radio():
components = ui.build_t2i_tab()
assert isinstance(components["model"], gr.Radio)
assert components["model"].value == "Turbo"
# Confirm the radio carries both choices. Gradio stores them as (label, value)
# tuples on the .choices attribute.
values = [c[1] for c in components["model"].choices]
assert values == ["Base", "Turbo"]
def test_build_t2i_tab_lora_group_starts_hidden():
components = ui.build_t2i_tab()
assert components["lora_group"].visible is False
assert components["lora_enabled"].value is False
def test_build_t2i_tab_base_group_starts_hidden():
"""Turbo is the default model, so the Base-only fields are hidden up front."""
components = ui.build_t2i_tab()
assert components["base_group"].visible is False
def test_build_controlnet_tab_returns_components():
components = ui.build_controlnet_tab()
expected = {
"prompt",
"input_image",
"preview_image",
"preprocessor",
"controlnet_scale",
"steps",
"seed",
"lora_enabled",
"lora_group",
"lora_path",
"lora_strength",
"generate_btn",
"output_image",
"output_meta",
}
assert expected.issubset(components.keys())
def test_build_controlnet_tab_preview_is_non_interactive_image():
components = ui.build_controlnet_tab()
assert isinstance(components["preview_image"], gr.Image)
assert components["preview_image"].interactive is False
def test_build_upscale_tab_returns_components():
components = ui.build_upscale_tab()
expected = {
"prompt",
"input_image",
"refine_steps",
"refine_denoise",
"seed",
"generate_btn",
"output_image",
"output_meta",
}
assert expected.issubset(components.keys())
def test_build_upscale_tab_has_no_lora_components():
"""LoRA is intentionally not wired on Upscale — the refinement pass uses
too low a denoising window for style LoRAs to meaningfully apply."""
components = ui.build_upscale_tab()
for key in ("lora_enabled", "lora_group", "lora_path", "lora_strength"):
assert key not in components
|