Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kombu/transport/gcpubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def _put(self, queue, message, **kwargs):
qdesc.topic_path,
encoded_message.encode("utf-8"),
routing_key=routing_key,
retry=Retry(deadline=self.retry_timeout_seconds),
)

def _put_fanout(self, exchange, message, routing_key, **kwargs):
Expand Down
34 changes: 32 additions & 2 deletions t/unit/transport/test_gcpubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from concurrent.futures import Future
from datetime import datetime
from queue import Empty
from unittest.mock import MagicMock, call, patch
from unittest.mock import ANY, MagicMock, call, patch

import pytest
from _socket import timeout as socket_timeout
from google.api_core.exceptions import (AlreadyExists, DeadlineExceeded,
PermissionDenied)
from google.api_core.retry import Retry
from google.pubsub_v1.types.pubsub import Subscription

from kombu.transport.gcpubsub import (AtomicCounter, Channel, QueueDescriptor,
Expand Down Expand Up @@ -328,8 +329,37 @@ def test_put(self, channel):
)
channel._get_routing_key = MagicMock(return_value="test_key")
channel.publisher.publish = MagicMock()
channel.retry_timeout_seconds = 300
channel._put(queue, message)
channel.publisher.publish.assert_called_once()
channel.publisher.publish.assert_called_once_with(
"topic_path",
ANY,
routing_key="test_key",
retry=ANY,
)
call_kwargs = channel.publisher.publish.call_args[1]
assert isinstance(call_kwargs['retry'], Retry)
assert call_kwargs['retry']._timeout == 300
Comment on lines +340 to +342
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is asserting against Retry's private attribute ._timeout. This is not part of the public API and can change across google-api-core versions (and may not reflect the value passed via deadline=). Prefer asserting via a stable interface (e.g., patching kombu.transport.gcpubsub.Retry and checking it was constructed with deadline=..., or asserting on a public property if one exists in the supported versions).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this


def test_put_uses_custom_retry_timeout(self, channel):
queue = "test_queue"
message = {
"properties": {"delivery_info": {"routing_key": "test_key"}}
}
channel.entity_name = MagicMock(return_value=queue)
channel._queue_cache[channel.entity_name(queue)] = QueueDescriptor(
name=queue,
topic_path="topic_path",
subscription_id=queue,
subscription_path="subscription_path",
)
channel._get_routing_key = MagicMock(return_value="test_key")
channel.publisher.publish = MagicMock()
channel.retry_timeout_seconds = 60
channel._put(queue, message)
call_kwargs = channel.publisher.publish.call_args[1]
assert isinstance(call_kwargs['retry'], Retry)
assert call_kwargs['retry']._timeout == 60
Comment on lines +360 to +362
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion relies on the private Retry._timeout attribute, which is version-dependent and can make the test brittle. Consider validating the Retry configuration without reaching into private internals (e.g., by patching kombu.transport.gcpubsub.Retry and asserting it was called with the expected deadline).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please cross check this suggestion?


def test_put_fanout(self, channel):
exchange = "test_exchange"
Expand Down
Loading