Spaces:
Sleeping
Sleeping
Drop the comparison slider, drag the zoom point, allow 8 steps
Browse files- test_app_smoke.py +28 -6
test_app_smoke.py
CHANGED
|
@@ -49,9 +49,10 @@ def test_the_interface_builds(app):
|
|
| 49 |
assert app.demo.blocks and app.demo.fns
|
| 50 |
|
| 51 |
|
| 52 |
-
def
|
| 53 |
assert app.preview(photo, 4, 0.3, 0.7).size == (512, 512)
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def test_declared_duration_grows_with_depth(app, photo):
|
|
@@ -60,11 +61,24 @@ def test_declared_duration_grows_with_depth(app, photo):
|
|
| 60 |
|
| 61 |
|
| 62 |
def test_the_shipped_example_assets_exist(app):
|
| 63 |
-
for path in [app.EXAMPLE_CLIP, *
|
| 64 |
assert os.path.getsize(path) > 1000, path
|
| 65 |
assert [label for _, label in app.EXAMPLE_LEVELS] == ["input", "4x", "16x", "64x", "256x"]
|
| 66 |
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def test_every_sample_named_for_the_examples_is_present(app):
|
| 69 |
for name in app.SAMPLES:
|
| 70 |
assert os.path.exists(f"samples/{name}.png")
|
|
@@ -73,11 +87,10 @@ def test_every_sample_named_for_the_examples_is_present(app):
|
|
| 73 |
def test_run_streams_one_update_per_level_then_the_clip(app, photo):
|
| 74 |
yields = list(app.run(photo, 3, 0.5, 0.5))
|
| 75 |
assert len(yields) == 5 # entry level, 3 zoom steps, then the clip
|
| 76 |
-
assert all(len(y) ==
|
| 77 |
assert yields[0][1] is None # first yield clears any stale clip
|
| 78 |
-
status, clip, gallery,
|
| 79 |
assert [label for _, label in gallery] == ["input", "4x", "16x", "64x"]
|
| 80 |
-
assert compare is not None and len(compare) == 2
|
| 81 |
assert prompts.count("tag") == 3
|
| 82 |
try:
|
| 83 |
assert os.path.getsize(clip) > 10_000
|
|
@@ -85,6 +98,15 @@ def test_run_streams_one_update_per_level_then_the_clip(app, photo):
|
|
| 85 |
os.remove(clip)
|
| 86 |
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
def test_run_rejects_an_empty_upload(app):
|
| 89 |
import gradio as gr
|
| 90 |
with pytest.raises(gr.Error):
|
|
|
|
| 49 |
assert app.demo.blocks and app.demo.fns
|
| 50 |
|
| 51 |
|
| 52 |
+
def test_preview_returns_a_canvas_for_an_upload_and_for_nothing_yet(app, photo):
|
| 53 |
assert app.preview(photo, 4, 0.3, 0.7).size == (512, 512)
|
| 54 |
+
# Never None: a visitor touching a slider before uploading must not blank the overlay.
|
| 55 |
+
assert app.preview(None, 4, 0.5, 0.5).size == (512, 512)
|
| 56 |
|
| 57 |
|
| 58 |
def test_declared_duration_grows_with_depth(app, photo):
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
def test_the_shipped_example_assets_exist(app):
|
| 64 |
+
for path in [app.EXAMPLE_CLIP, *(p for p, _ in app.EXAMPLE_LEVELS)]:
|
| 65 |
assert os.path.getsize(path) > 1000, path
|
| 66 |
assert [label for _, label in app.EXAMPLE_LEVELS] == ["input", "4x", "16x", "64x", "256x"]
|
| 67 |
|
| 68 |
|
| 69 |
+
def test_labels_cover_every_depth_the_slider_offers(app):
|
| 70 |
+
got = [app.label(app.UPSCALE ** n) for n in range(app.MAX_STEPS + 1)]
|
| 71 |
+
assert got[0] == "input"
|
| 72 |
+
assert got[-1] == "65536x"
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def test_the_citation_is_the_one_from_the_readme(app):
|
| 76 |
+
readme = open(os.path.join(os.path.dirname(app.__file__), "..", "README.md")).read()
|
| 77 |
+
assert "2609.06490" in app.BIBTEX and "dipta2026oraclezoom" in app.BIBTEX
|
| 78 |
+
for line in app.BIBTEX.splitlines():
|
| 79 |
+
assert line.strip() in " ".join(readme.split()) or line.strip() in readme, line
|
| 80 |
+
|
| 81 |
+
|
| 82 |
def test_every_sample_named_for_the_examples_is_present(app):
|
| 83 |
for name in app.SAMPLES:
|
| 84 |
assert os.path.exists(f"samples/{name}.png")
|
|
|
|
| 87 |
def test_run_streams_one_update_per_level_then_the_clip(app, photo):
|
| 88 |
yields = list(app.run(photo, 3, 0.5, 0.5))
|
| 89 |
assert len(yields) == 5 # entry level, 3 zoom steps, then the clip
|
| 90 |
+
assert all(len(y) == 4 for y in yields)
|
| 91 |
assert yields[0][1] is None # first yield clears any stale clip
|
| 92 |
+
status, clip, gallery, prompts = yields[-1]
|
| 93 |
assert [label for _, label in gallery] == ["input", "4x", "16x", "64x"]
|
|
|
|
| 94 |
assert prompts.count("tag") == 3
|
| 95 |
try:
|
| 96 |
assert os.path.getsize(clip) > 10_000
|
|
|
|
| 98 |
os.remove(clip)
|
| 99 |
|
| 100 |
|
| 101 |
+
def test_a_deep_run_labels_every_level(app, photo):
|
| 102 |
+
status, clip, gallery, prompts = list(app.run(photo, app.MAX_STEPS, 0.5, 0.5))[-1]
|
| 103 |
+
try:
|
| 104 |
+
assert [label for _, label in gallery] == [
|
| 105 |
+
"input", "4x", "16x", "64x", "256x", "1024x", "4096x", "16384x", "65536x"]
|
| 106 |
+
finally:
|
| 107 |
+
os.remove(clip)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
def test_run_rejects_an_empty_upload(app):
|
| 111 |
import gradio as gr
|
| 112 |
with pytest.raises(gr.Error):
|