Skip to content

Commit 08299da

Browse files
committed
adding tests
1 parent f198f77 commit 08299da

File tree

2 files changed

+7
-7
lines changed
  • instrumentation/opentelemetry-instrumentation-pika

2 files changed

+7
-7
lines changed

instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def _enrich_span(
199199
)
200200

201201

202+
# pylint:disable=abstract-method
202203
class ReadyMessagesDequeProxy(ObjectProxy):
203204
def __init__(
204205
self,
@@ -225,7 +226,7 @@ def popleft(self, *args, **kwargs):
225226

226227
try:
227228
# If a new message was received, create a span and set as active context
228-
if type(evt) is _ConsumerDeliveryEvt:
229+
if isinstance(evt, _ConsumerDeliveryEvt):
229230
method = evt.method
230231
properties = evt.properties
231232
if not properties:

instrumentation/opentelemetry-instrumentation-pika/tests/test_utils.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def test_decorate_basic_publish_when_span_is_not_recording(
455455
)
456456
self.assertEqual(retval, callback.return_value)
457457

458+
# pylint: disable=too-many-statements
458459
@mock.patch("opentelemetry.instrumentation.pika.utils._get_span")
459460
@mock.patch("opentelemetry.propagate.extract")
460461
@mock.patch("opentelemetry.context.detach")
@@ -471,18 +472,16 @@ def test_decorate_deque_proxy(
471472
returned_span = mock.MagicMock()
472473
get_span.return_value = returned_span
473474
consume_hook = mock.MagicMock()
474-
mock_task_name = "mock_task_name"
475475
tracer = mock.MagicMock()
476476
generator_info = mock.MagicMock(
477477
spec=_QueueConsumerGeneratorInfo,
478478
pending_events=mock.MagicMock(spec=collections.deque),
479-
consumer_tag=mock_task_name,
479+
consumer_tag="mock_task_name",
480480
)
481481
method = mock.MagicMock(spec=Basic.Deliver)
482482
method.exchange = "test_exchange"
483483
properties = mock.MagicMock()
484-
mock_body = b"mock_body"
485-
evt = _ConsumerDeliveryEvt(method, properties, mock_body)
484+
evt = _ConsumerDeliveryEvt(method, properties, b"mock_body")
486485
generator_info.pending_events.popleft.return_value = evt
487486
proxy = utils.ReadyMessagesDequeProxy(
488487
generator_info.pending_events, generator_info, tracer, consume_hook
@@ -504,7 +503,7 @@ def test_decorate_deque_proxy(
504503
properties,
505504
destination=method.exchange,
506505
span_kind=SpanKind.CONSUMER,
507-
task_name=mock_task_name,
506+
task_name=generator_info.consumer_tag,
508507
operation=MessagingOperationValues.RECEIVE,
509508
)
510509
consume_hook.assert_called_once()
@@ -535,7 +534,7 @@ def test_decorate_deque_proxy(
535534
properties,
536535
destination=method.exchange,
537536
span_kind=SpanKind.CONSUMER,
538-
task_name=mock_task_name,
537+
task_name=generator_info.consumer_tag,
539538
operation=MessagingOperationValues.RECEIVE,
540539
)
541540
consume_hook.assert_called_once()

0 commit comments

Comments
 (0)