|
| 1 | +import os |
| 2 | +import re |
1 | 3 | from unittest.mock import MagicMock, patch |
2 | 4 |
|
3 | 5 | import pytest |
| 6 | +import requests |
4 | 7 |
|
5 | | -from comfy_cli.standalone import _resolve_python_version, download_standalone_python |
| 8 | +from comfy_cli.standalone import ( |
| 9 | + _latest_release_json_url, |
| 10 | + _resolve_python_version, |
| 11 | + download_standalone_python, |
| 12 | +) |
6 | 13 |
|
7 | 14 | # Minimal SHA256SUMS content matching real format |
8 | 15 | SAMPLE_SHA256SUMS = """\ |
@@ -112,3 +119,53 @@ def test_full_version_skips_resolution(self, mock_get, mock_download): |
112 | 119 |
|
113 | 120 | # Should have fetched only latest-release.json, not SHA256SUMS |
114 | 121 | assert mock_get.call_count == 1 |
| 122 | + |
| 123 | + |
| 124 | +_require_network = pytest.mark.skipif( |
| 125 | + os.getenv("TEST_NETWORK", "false").lower() != "true", |
| 126 | + reason="Set TEST_NETWORK=true to run integration tests that hit the network", |
| 127 | +) |
| 128 | + |
| 129 | + |
| 130 | +@_require_network |
| 131 | +class TestResolveVersionIntegration: |
| 132 | + """Integration tests that hit the real python-build-standalone release endpoints.""" |
| 133 | + |
| 134 | + def test_latest_release_json_is_reachable(self): |
| 135 | + response = requests.get(_latest_release_json_url) |
| 136 | + assert response.status_code == 200 |
| 137 | + data = response.json() |
| 138 | + assert "tag" in data |
| 139 | + assert "asset_url_prefix" in data |
| 140 | + # tag should be a date string like "20260310" |
| 141 | + assert re.fullmatch(r"\d{8}", data["tag"]), f"unexpected tag format: {data['tag']}" |
| 142 | + |
| 143 | + def test_resolve_312_from_real_release(self): |
| 144 | + response = requests.get(_latest_release_json_url) |
| 145 | + data = response.json() |
| 146 | + asset_url_prefix = data["asset_url_prefix"] |
| 147 | + |
| 148 | + version = _resolve_python_version(asset_url_prefix, "3.12") |
| 149 | + |
| 150 | + # Should be a valid 3.12.x version |
| 151 | + assert re.fullmatch(r"3\.12\.\d+", version), f"unexpected version: {version}" |
| 152 | + |
| 153 | + def test_sha256sums_contains_expected_platforms(self): |
| 154 | + """Verify the platforms we use in _platform_targets actually exist in the release.""" |
| 155 | + response = requests.get(_latest_release_json_url) |
| 156 | + data = response.json() |
| 157 | + asset_url_prefix = data["asset_url_prefix"] |
| 158 | + |
| 159 | + sha256sums_url = f"{asset_url_prefix}/SHA256SUMS" |
| 160 | + sha_response = requests.get(sha256sums_url) |
| 161 | + assert sha_response.status_code == 200 |
| 162 | + |
| 163 | + content = sha_response.text |
| 164 | + expected_targets = [ |
| 165 | + "aarch64-apple-darwin", |
| 166 | + "x86_64-apple-darwin", |
| 167 | + "x86_64_v3-unknown-linux-gnu", |
| 168 | + "x86_64-pc-windows-msvc", |
| 169 | + ] |
| 170 | + for target in expected_targets: |
| 171 | + assert target in content, f"platform target '{target}' not found in SHA256SUMS" |
0 commit comments