junaid-simamdigital commited on
Commit
f38e377
·
verified ·
1 Parent(s): 3981cf9

test: cover empty hosted output slots

Browse files
Files changed (1) hide show
  1. tests/test_hosted_smoke_test.py +13 -2
tests/test_hosted_smoke_test.py CHANGED
@@ -1,13 +1,13 @@
1
  from pathlib import Path
2
  from unittest.mock import patch
3
 
4
- from hosted_smoke_test import run
5
 
6
 
7
  def test_hosted_smoke_orchestrates_upload_event_and_output_contract(tmp_path):
8
  image = tmp_path / "input.png"
9
  image.write_bytes(b"test image")
10
- result = [None] * 11 + ["manifest.json", "### analysis single_view_baseline", "Processed 1 view(s) on CUDA"]
11
  uploaded = {"path": "/tmp/gradio/input.png", "url": "https://example.test/gradio_api/file=/tmp/gradio/input.png"}
12
  with patch("hosted_smoke_test.upload_image", return_value=uploaded) as upload:
13
  with patch("hosted_smoke_test.request_json", return_value={"event_id": "event-1"}) as request:
@@ -35,3 +35,14 @@ def test_hosted_smoke_rejects_incomplete_output_contract(tmp_path):
35
  assert "Expected 14 generated outputs" in str(exc)
36
  else:
37
  raise AssertionError("incomplete hosted output should fail")
 
 
 
 
 
 
 
 
 
 
 
 
1
  from pathlib import Path
2
  from unittest.mock import patch
3
 
4
+ from hosted_smoke_test import run, validate_output_bundle
5
 
6
 
7
  def test_hosted_smoke_orchestrates_upload_event_and_output_contract(tmp_path):
8
  image = tmp_path / "input.png"
9
  image.write_bytes(b"test image")
10
+ result = [f"output-{index}" for index in range(11)] + ["manifest.json", "### analysis single_view_baseline", "Processed 1 view(s) on CUDA"]
11
  uploaded = {"path": "/tmp/gradio/input.png", "url": "https://example.test/gradio_api/file=/tmp/gradio/input.png"}
12
  with patch("hosted_smoke_test.upload_image", return_value=uploaded) as upload:
13
  with patch("hosted_smoke_test.request_json", return_value={"event_id": "event-1"}) as request:
 
35
  assert "Expected 14 generated outputs" in str(exc)
36
  else:
37
  raise AssertionError("incomplete hosted output should fail")
38
+
39
+
40
+ def test_hosted_smoke_rejects_empty_slot_in_complete_bundle():
41
+ result = [f"output-{index}" for index in range(14)]
42
+ result[6] = None
43
+ try:
44
+ validate_output_bundle(result)
45
+ except RuntimeError as exc:
46
+ assert "empty slots: [6]" in str(exc)
47
+ else:
48
+ raise AssertionError("empty hosted output slot should fail")