|
21 | 21 |
|
22 | 22 | import json |
23 | 23 | import logging |
| 24 | +from unittest import mock |
24 | 25 |
|
25 | 26 | import pytest |
26 | 27 | from aiohttp import web |
@@ -430,16 +431,20 @@ async def test_retries_then_success(self): |
430 | 431 | "secr3t password", |
431 | 432 | ) |
432 | 433 |
|
433 | | - response = await client.send_notification( |
434 | | - "my-namespace", |
435 | | - "my-cluster", |
436 | | - WebhookEvent.UPGRADE, |
437 | | - WebhookUpgradePayload( |
438 | | - old_registry="a", new_registry="b", old_version="c", new_version="d" |
439 | | - ), |
440 | | - WebhookStatus.SUCCESS, |
441 | | - logging.getLogger(__name__), |
442 | | - ) |
| 434 | + with ( |
| 435 | + mock.patch("crate.operator.config.config.TESTING", False), |
| 436 | + mock.patch("crate.operator.webhooks.RETRY_BASE_DELAY", 0.001), |
| 437 | + ): |
| 438 | + response = await client.send_notification( |
| 439 | + "my-namespace", |
| 440 | + "my-cluster", |
| 441 | + WebhookEvent.UPGRADE, |
| 442 | + WebhookUpgradePayload( |
| 443 | + old_registry="a", new_registry="b", old_version="c", new_version="d" |
| 444 | + ), |
| 445 | + WebhookStatus.SUCCESS, |
| 446 | + logging.getLogger(__name__), |
| 447 | + ) |
443 | 448 |
|
444 | 449 | assert response.status == 200 |
445 | 450 | assert self.app["calls"] == 3 |
@@ -473,16 +478,20 @@ async def test_retry_exhausted(self): |
473 | 478 | "secr3t password", |
474 | 479 | ) |
475 | 480 |
|
476 | | - response = await client.send_notification( |
477 | | - "my-namespace", |
478 | | - "my-cluster", |
479 | | - WebhookEvent.UPGRADE, |
480 | | - WebhookUpgradePayload( |
481 | | - old_registry="a", new_registry="b", old_version="c", new_version="d" |
482 | | - ), |
483 | | - WebhookStatus.SUCCESS, |
484 | | - logging.getLogger(__name__), |
485 | | - ) |
| 481 | + with ( |
| 482 | + mock.patch("crate.operator.config.config.TESTING", False), |
| 483 | + mock.patch("crate.operator.webhooks.RETRY_BASE_DELAY", 0.001), |
| 484 | + ): |
| 485 | + response = await client.send_notification( |
| 486 | + "my-namespace", |
| 487 | + "my-cluster", |
| 488 | + WebhookEvent.UPGRADE, |
| 489 | + WebhookUpgradePayload( |
| 490 | + old_registry="a", new_registry="b", old_version="c", new_version="d" |
| 491 | + ), |
| 492 | + WebhookStatus.SUCCESS, |
| 493 | + logging.getLogger(__name__), |
| 494 | + ) |
486 | 495 |
|
487 | 496 | assert response.status == 502 |
488 | 497 | assert self.app["calls"] == RETRY_MAX_ATTEMPTS |
0 commit comments