|
7 | 7 | from hcloud.actions import ( |
8 | 8 | Action, |
9 | 9 | ActionFailedException, |
| 10 | + ActionGroupException, |
10 | 11 | ActionsClient, |
11 | 12 | ActionTimeoutException, |
12 | 13 | BoundAction, |
@@ -258,3 +259,29 @@ def test_wait_for_error(self, actions_client: ActionsClient): |
258 | 259 | mock.call(method="GET", url="/actions", params={"id": (1, 2)}), |
259 | 260 | ] |
260 | 261 | ) |
| 262 | + |
| 263 | + def test_wait_for_timeout(self, actions_client: ActionsClient): |
| 264 | + actions = [ |
| 265 | + Action(id=1, status="running", command="create_server"), |
| 266 | + Action(id=2, status="running", command="start_server"), |
| 267 | + ] |
| 268 | + |
| 269 | + # Speed up test by not really waiting |
| 270 | + actions_client._client._poll_interval_func = mock.MagicMock() |
| 271 | + actions_client._client._poll_interval_func.return_value = 0.1 |
| 272 | + |
| 273 | + actions_client._client.request.return_value = { |
| 274 | + "actions": [ |
| 275 | + {"id": 1, "status": "running", "command": "create_server"}, |
| 276 | + {"id": 2, "status": "running", "command": "start_server"}, |
| 277 | + ] |
| 278 | + } |
| 279 | + |
| 280 | + with pytest.raises(ActionGroupException): |
| 281 | + actions_client.wait_for(actions, timeout=0.2) |
| 282 | + |
| 283 | + actions_client._client.request.assert_has_calls( |
| 284 | + [ |
| 285 | + mock.call(method="GET", url="/actions", params={"id": (1, 2)}), |
| 286 | + ] |
| 287 | + ) |
0 commit comments