test_cloud_integration.py 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. """Integration tests against the live Comfy Cloud API.
  2. These tests are auto-skipped when COMFY_CLOUD_API_KEY is not set.
  3. They never SUBMIT workflows (would need a paid subscription) — they only
  4. verify the read-only endpoints we rely on.
  5. """
  6. from __future__ import annotations
  7. import pytest
  8. from _common import http_get, parse_model_list, resolve_url
  9. pytestmark = pytest.mark.cloud
  10. class TestCloudEndpointsLive:
  11. def test_system_stats_reachable(self, cloud_key):
  12. url = resolve_url("https://cloud.comfy.org", "/system_stats")
  13. r = http_get(url, headers={"X-API-Key": cloud_key})
  14. assert r.status == 200
  15. data = r.json()
  16. assert "system" in data
  17. def test_models_endpoint_routed_to_experiment(self, cloud_key):
  18. # We expect the skill to route /models/checkpoints → /api/experiment/models/checkpoints
  19. url = resolve_url("https://cloud.comfy.org", "/models/checkpoints")
  20. assert "/api/experiment/models/checkpoints" in url
  21. r = http_get(url, headers={"X-API-Key": cloud_key})
  22. assert r.status == 200
  23. def test_models_endpoint_returns_dicts(self, cloud_key):
  24. url = resolve_url("https://cloud.comfy.org", "/models/checkpoints")
  25. r = http_get(url, headers={"X-API-Key": cloud_key})
  26. data = r.json()
  27. assert isinstance(data, list)
  28. if data:
  29. # Cloud format: list of dicts with `name`
  30. assert isinstance(data[0], dict)
  31. assert "name" in data[0]
  32. # Our parser normalizes both
  33. normalized = parse_model_list(data)
  34. assert len(normalized) == len(data)
  35. def test_history_renamed_to_v2(self, cloud_key):
  36. # /history → /api/history_v2 on cloud
  37. url = resolve_url("https://cloud.comfy.org", "/history/some-fake-id")
  38. assert "/api/history_v2/some-fake-id" in url
  39. def test_object_info_paid_tier(self, cloud_key):
  40. # On free tier, /object_info returns 403 with a recognizable message
  41. url = resolve_url("https://cloud.comfy.org", "/object_info")
  42. r = http_get(url, headers={"X-API-Key": cloud_key})
  43. # Should be either 200 (paid) or 403 (free) — not 404 / 500
  44. assert r.status in {200, 403}
  45. if r.status == 403:
  46. # Body should mention the limitation
  47. assert "free tier" in r.text().lower() or "subscription" in r.text().lower()
  48. class TestCloudCheckDepsLive:
  49. def test_check_deps_against_cloud(self, cloud_key, sd15_workflow):
  50. from check_deps import check_deps
  51. report = check_deps(sd15_workflow, host="https://cloud.comfy.org", api_key=cloud_key)
  52. # Either node check passed OR was skipped (free tier)
  53. assert "missing_models" in report
  54. assert "is_cloud" in report and report["is_cloud"] is True
  55. def test_flux_workflow_models_resolved_via_aliases(self, cloud_key, flux_workflow):
  56. """Flux uses unet/clip folders; cloud has them in diffusion_models/text_encoders.
  57. With folder aliasing, the check should still find them."""
  58. from check_deps import check_deps
  59. report = check_deps(flux_workflow, host="https://cloud.comfy.org", api_key=cloud_key)
  60. # The exact required Flux files (flux1-dev.safetensors, t5xxl_fp16, clip_l, ae)
  61. # are present on cloud; with folder aliasing, none should be missing.
  62. # If this fails, either the cloud removed the model or the aliasing logic broke.
  63. missing_filenames = {m["value"] for m in report["missing_models"]}
  64. assert "ae.safetensors" not in missing_filenames, \
  65. "ae.safetensors should be on cloud's vae folder"
  66. # t5xxl_fp16 / clip_l should be reachable via the clip → text_encoders alias
  67. # flux1-dev.safetensors likewise via unet → diffusion_models
  68. class TestHealthCheckLive:
  69. def test_health_check_passes(self, cloud_key, capsys):
  70. from health_check import main as health_main
  71. health_main(["--host", "https://cloud.comfy.org", "--api-key", cloud_key])
  72. captured = capsys.readouterr()
  73. # Should produce JSON
  74. import json
  75. report = json.loads(captured.out)
  76. assert report["server"]["reachable"] is True
  77. assert report["checkpoints"]["queryable"] is True
  78. assert report["checkpoints"]["count"] > 0