Skip to content

Commit

Permalink
wip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galbash committed Apr 8, 2024
1 parent f9ee608 commit 6f06250
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def wrapper(wrapped, instance, args, kwargs):
)

def _instrument(self, **kwargs: Dict[str, Any]) -> None:
print("in instrument 1")
tracer_provider: TracerProvider = kwargs.get("tracer_provider", None)
publish_hook: utils.HookT = kwargs.get(
"publish_hook", utils.dummy_callback
Expand All @@ -228,6 +229,8 @@ def _instrument(self, **kwargs: Dict[str, Any]) -> None:
consume_hook=consume_hook,
)


print("in instrument 2")
self._decorate_queue_consumer_generator(
tracer_provider, consume_hook=consume_hook
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from unittest import TestCase, mock

from pika.adapters import BlockingConnection
from pika.adapters.blocking_connection import _QueueConsumerGeneratorInfo
from pika.channel import Channel
from wrapt import BoundFunctionWrapper

Expand All @@ -40,6 +41,9 @@ def test_instrument_api(self) -> None:
self.assertTrue(
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
)
self.assertTrue(
isinstance(_QueueConsumerGeneratorInfo.__init__, BoundFunctionWrapper)
)
assert hasattr(
instrumentation, "__opentelemetry_tracer_provider"
), "Tracer not stored for the object!"
Expand All @@ -57,15 +61,11 @@ def test_instrument_api(self) -> None:
@mock.patch(
"opentelemetry.instrumentation.pika.PikaInstrumentor._instrument_blocking_channel_consumers"
)
@mock.patch(
"opentelemetry.instrumentation.pika.PikaInstrumentor._decorate_queue_consumer_generator"
)
def test_instrument(
def test_instrument_channel(
self,
instrument_blocking_channel_consumers: mock.MagicMock,
instrument_basic_consume: mock.MagicMock,
instrument_channel_functions: mock.MagicMock,
instrument_queue_consumer_generator: mock.MagicMock,
):
PikaInstrumentor.instrument_channel(channel=self.channel)
assert hasattr(
Expand All @@ -74,7 +74,6 @@ def test_instrument(
instrument_blocking_channel_consumers.assert_called_once()
instrument_basic_consume.assert_called_once()
instrument_channel_functions.assert_called_once()
instrument_queue_consumer_generator.assert_called_once()

@mock.patch("opentelemetry.instrumentation.pika.utils._decorate_callback")
def test_instrument_consumers(
Expand Down

0 comments on commit 6f06250

Please sign in to comment.