junaid-simamdigital commited on
Commit
8e29cf5
·
verified ·
1 Parent(s): 95b0c34

Test portable hosted input payload

Browse files
Files changed (1) hide show
  1. tests/test_hosted_smoke_test.py +4 -3
tests/test_hosted_smoke_test.py CHANGED
@@ -8,14 +8,15 @@ 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
- with patch("hosted_smoke_test.upload_image", return_value="/tmp/gradio/input.png") as upload:
 
12
  with patch("hosted_smoke_test.request_json", return_value={"event_id": "event-1"}) as request:
13
  with patch("hosted_smoke_test.poll_event", return_value=result) as poll:
14
  summary = run("https://example.test/", image, timeout=10)
15
  upload.assert_called_once_with("https://example.test", image)
16
  request.assert_called_once_with(
17
  "https://example.test/gradio_api/call/generate",
18
- {"data": [{"path": "/tmp/gradio/input.png"}, [], "Depth Anything V2 (stable baseline)", "hosted smoke test", True]},
19
  )
20
  poll.assert_called_once_with("https://example.test", "generate", "event-1", 10)
21
  assert summary["output_count"] == 14
@@ -25,7 +26,7 @@ def test_hosted_smoke_orchestrates_upload_event_and_output_contract(tmp_path):
25
  def test_hosted_smoke_rejects_incomplete_output_contract(tmp_path):
26
  image = tmp_path / "input.png"
27
  image.write_bytes(b"test image")
28
- with patch("hosted_smoke_test.upload_image", return_value="/tmp/gradio/input.png"):
29
  with patch("hosted_smoke_test.request_json", return_value={"event_id": "event-1"}):
30
  with patch("hosted_smoke_test.poll_event", return_value=[None] * 13):
31
  try:
 
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:
14
  with patch("hosted_smoke_test.poll_event", return_value=result) as poll:
15
  summary = run("https://example.test/", image, timeout=10)
16
  upload.assert_called_once_with("https://example.test", image)
17
  request.assert_called_once_with(
18
  "https://example.test/gradio_api/call/generate",
19
+ {"data": [uploaded, [], "Depth Anything V2 (stable baseline)", "hosted smoke test", True]},
20
  )
21
  poll.assert_called_once_with("https://example.test", "generate", "event-1", 10)
22
  assert summary["output_count"] == 14
 
26
  def test_hosted_smoke_rejects_incomplete_output_contract(tmp_path):
27
  image = tmp_path / "input.png"
28
  image.write_bytes(b"test image")
29
+ with patch("hosted_smoke_test.upload_image", return_value={"path": "/tmp/gradio/input.png"}):
30
  with patch("hosted_smoke_test.request_json", return_value={"event_id": "event-1"}):
31
  with patch("hosted_smoke_test.poll_event", return_value=[None] * 13):
32
  try: