|
3 | 3 | import json |
4 | 4 | from pathlib import Path |
5 | 5 |
|
| 6 | +from codex_logdatenbank_wartung import store_release |
6 | 7 | from codex_logdatenbank_wartung.store_release import validate_store_materials |
7 | 8 |
|
8 | 9 |
|
@@ -97,6 +98,112 @@ def test_validate_store_materials_reports_ok_for_complete_materials(tmp_path: Pa |
97 | 98 | assert pages_build_check.status == "ok" |
98 | 99 |
|
99 | 100 |
|
| 101 | +def test_validate_store_materials_checks_live_pages_on_request( |
| 102 | + tmp_path: Path, |
| 103 | + monkeypatch, |
| 104 | +) -> None: |
| 105 | + class FakeResponse: |
| 106 | + status = 200 |
| 107 | + |
| 108 | + def __enter__(self): |
| 109 | + return self |
| 110 | + |
| 111 | + def __exit__(self, *_args) -> None: |
| 112 | + return None |
| 113 | + |
| 114 | + requested_urls: list[str] = [] |
| 115 | + |
| 116 | + def fake_urlopen(request, *, timeout: float): |
| 117 | + requested_urls.append(request.full_url) |
| 118 | + assert timeout == 10.0 |
| 119 | + return FakeResponse() |
| 120 | + |
| 121 | + monkeypatch.setattr(store_release.urlrequest, "urlopen", fake_urlopen) |
| 122 | + exe_path = tmp_path / "CareCenterForCodex.exe" |
| 123 | + exe_path.write_bytes(b"exe") |
| 124 | + _write_store_files( |
| 125 | + tmp_path, |
| 126 | + { |
| 127 | + "app_name": "CareCenter for Codex", |
| 128 | + "publisher": "CN=01234567-89AB-CDEF-0123-456789ABCDEF", |
| 129 | + "publisher_display": "Lukas Geiger", |
| 130 | + "identity_name": "LukasGeiger.CareCenterForCodex", |
| 131 | + "version": "0.8.0.0", |
| 132 | + "description": "Offline Wartung und Reparatur fuer die Codex-Desktop-App.", |
| 133 | + "executable": "CareCenterForCodex.exe", |
| 134 | + "capabilities": "runFullTrust", |
| 135 | + "category": "Developer Tools", |
| 136 | + "age_rating": "3+", |
| 137 | + "privacy_url": "https://dev-bricks.github.io/CareCenter-for-Codex/privacy", |
| 138 | + "support_url": "https://dev-bricks.github.io/CareCenter-for-Codex/support", |
| 139 | + }, |
| 140 | + ) |
| 141 | + |
| 142 | + report = validate_store_materials( |
| 143 | + project_root=tmp_path, |
| 144 | + exe_path=exe_path, |
| 145 | + check_live_pages=True, |
| 146 | + ) |
| 147 | + |
| 148 | + live_check = next(check for check in report.checks if check.name == "Store-Webseiten-Live") |
| 149 | + assert live_check.status == "ok" |
| 150 | + assert requested_urls == [ |
| 151 | + "https://dev-bricks.github.io/CareCenter-for-Codex/privacy", |
| 152 | + "https://dev-bricks.github.io/CareCenter-for-Codex/support", |
| 153 | + ] |
| 154 | + |
| 155 | + |
| 156 | +def test_validate_store_materials_warns_when_live_page_is_missing( |
| 157 | + tmp_path: Path, |
| 158 | + monkeypatch, |
| 159 | +) -> None: |
| 160 | + class FakeResponse: |
| 161 | + def __init__(self, status: int) -> None: |
| 162 | + self.status = status |
| 163 | + |
| 164 | + def __enter__(self): |
| 165 | + return self |
| 166 | + |
| 167 | + def __exit__(self, *_args) -> None: |
| 168 | + return None |
| 169 | + |
| 170 | + def fake_urlopen(request, *, timeout: float): |
| 171 | + del timeout |
| 172 | + status = 404 if request.full_url.endswith("/support") else 200 |
| 173 | + return FakeResponse(status) |
| 174 | + |
| 175 | + monkeypatch.setattr(store_release.urlrequest, "urlopen", fake_urlopen) |
| 176 | + exe_path = tmp_path / "CareCenterForCodex.exe" |
| 177 | + exe_path.write_bytes(b"exe") |
| 178 | + _write_store_files( |
| 179 | + tmp_path, |
| 180 | + { |
| 181 | + "app_name": "CareCenter for Codex", |
| 182 | + "publisher": "CN=01234567-89AB-CDEF-0123-456789ABCDEF", |
| 183 | + "publisher_display": "Lukas Geiger", |
| 184 | + "identity_name": "LukasGeiger.CareCenterForCodex", |
| 185 | + "version": "0.8.0.0", |
| 186 | + "description": "Offline Wartung und Reparatur fuer die Codex-Desktop-App.", |
| 187 | + "executable": "CareCenterForCodex.exe", |
| 188 | + "capabilities": "runFullTrust", |
| 189 | + "category": "Developer Tools", |
| 190 | + "age_rating": "3+", |
| 191 | + "privacy_url": "https://dev-bricks.github.io/CareCenter-for-Codex/privacy", |
| 192 | + "support_url": "https://dev-bricks.github.io/CareCenter-for-Codex/support", |
| 193 | + }, |
| 194 | + ) |
| 195 | + |
| 196 | + report = validate_store_materials( |
| 197 | + project_root=tmp_path, |
| 198 | + exe_path=exe_path, |
| 199 | + check_live_pages=True, |
| 200 | + ) |
| 201 | + |
| 202 | + live_check = next(check for check in report.checks if check.name == "Store-Webseiten-Live") |
| 203 | + assert live_check.status == "warning" |
| 204 | + assert "support_url: HTTP 404" in live_check.message |
| 205 | + |
| 206 | + |
100 | 207 | def test_validate_store_materials_auto_detects_built_exe_from_build_script(tmp_path: Path) -> None: |
101 | 208 | dist_dir = tmp_path / "_local" / "bin" |
102 | 209 | dist_dir.mkdir(parents=True) |
|
0 commit comments