|
6 | 6 | from contextlib import nullcontext as does_not_raise |
7 | 7 | from pathlib import Path |
8 | 8 | from typing import Any, cast |
| 9 | +from unittest.mock import Mock |
9 | 10 |
|
10 | 11 | import pytest |
11 | 12 |
|
@@ -258,3 +259,33 @@ def test_update_whatsnew_toctree(tmp_path: Path) -> None: |
258 | 259 | # Assert |
259 | 260 | new_contents = toctree__file.read_text() |
260 | 261 | assert " 3.15.rst\n 3.14.rst\n" in new_contents |
| 262 | + |
| 263 | + |
| 264 | +@pytest.mark.parametrize( |
| 265 | + ("version", "windows_file"), |
| 266 | + [ |
| 267 | + ("3.15.0a1", "python-3.15.0a1.exe"), |
| 268 | + ("3.16.0a1", "windows-3.16.0a1.json"), |
| 269 | + ], |
| 270 | +) |
| 271 | +def test_wait_until_all_files_are_in_folder_windows( |
| 272 | + monkeypatch: pytest.MonkeyPatch, version: str, windows_file: str |
| 273 | +) -> None: |
| 274 | + files = [f"Python-{version}.tgz", f"python-{version}-macos11.pkg"] |
| 275 | + client = Mock() |
| 276 | + ftp_client = client.open_sftp.return_value |
| 277 | + ftp_client.listdir.side_effect = [files, [*files, windows_file]] |
| 278 | + monkeypatch.setattr("run_release.paramiko.SSHClient", lambda: client) |
| 279 | + sleep = Mock() |
| 280 | + monkeypatch.setattr("run_release.time.sleep", sleep) |
| 281 | + db = { |
| 282 | + "release": Tag(version), |
| 283 | + "security_release": False, |
| 284 | + "ssh_user": "release-manager", |
| 285 | + "ssh_key": None, |
| 286 | + } |
| 287 | + |
| 288 | + run_release.wait_until_all_files_are_in_folder(cast(ReleaseShelf, db)) |
| 289 | + |
| 290 | + assert ftp_client.listdir.call_count == 2 |
| 291 | + sleep.assert_called_once_with(1) |
0 commit comments