From 2df978bc6811344625d46618e00d1aedc36a959e Mon Sep 17 00:00:00 2001 From: Oleh929216 Date: Sun, 20 Oct 2024 20:23:29 +0300 Subject: [PATCH] Added a unit test that proves timeout is used when retry policy is specified. (#2166) --- t/unit/test_messaging.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/unit/test_messaging.py b/t/unit/test_messaging.py index beefe44e..61ccaaf3 100644 --- a/t/unit/test_messaging.py +++ b/t/unit/test_messaging.py @@ -8,7 +8,7 @@ import pytest from kombu import Connection, Consumer, Exchange, Producer, Queue -from kombu.exceptions import MessageStateError +from kombu.exceptions import MessageStateError, OperationalError from kombu.utils import json from kombu.utils.functional import ChannelPromise from t.mocks import Transport @@ -156,6 +156,20 @@ def test_publish_with_timeout(self): timeout = p._channel.basic_publish.call_args[1]['timeout'] assert timeout == 1 + def test_publish_with_timeout_and_retry_policy(self): + p = self.connection.Producer() + p.channel = Mock() + p.channel.connection.client.declared_entities = set() + p.publish('test_timeout', exchange=Exchange('foo'), timeout=1, retry_policy={ + "max_retries": 20, + "interval_start": 1, + "interval_step": 2, + "interval_max": 30, + "retry_errors": (OperationalError,) + }) + timeout = p._channel.basic_publish.call_args[1]['timeout'] + assert timeout == 1 + def test_publish_with_reply_to(self): p = self.connection.Producer() p.channel = Mock()