Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Nov 19, 2024
1 parent d242454 commit 089c90a
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,42 @@ def test_instrument_connection_no_op_tracer_provider(self, mock_connect):
spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)

@mock.patch("opentelemetry.instrumentation.mysql.DatabaseApiIntegration")
@mock.patch("mysql.connector.connect")
# pylint: disable=unused-argument
def test_instrument_connection_enable_commenter(
self,
mock_connect,
mock_mysql_dbapi,
):
cnx, query = connect_and_execute_query()
cnx = MySQLInstrumentor().instrument_connection(
cnx,
enable_commenter=True,
commenter_options={"foo": True},
)
cursor = cnx.cursor()
cursor.execute(query)
kwargs = mock_mysql_dbapi.call_args[1]
self.assertEqual(kwargs["enable_commenter"], True)
self.assertEqual(kwargs["commenter_options"], {"foo": True})

@mock.patch("opentelemetry.instrumentation.dbapi.wrap_connect")
@mock.patch("mysql.connector.connect")
# pylint: disable=unused-argument
def test__instrument_enable_commenter(
self,
mock_connect,
mock_wrap_connect,
):
MySQLInstrumentor()._instrument(
enable_commenter=True,
commenter_options={"foo": True},
)
kwargs = mock_wrap_connect.call_args[1]
self.assertEqual(kwargs["enable_commenter"], True)
self.assertEqual(kwargs["commenter_options"], {"foo": True})

@mock.patch("mysql.connector.connect")
# pylint: disable=unused-argument
def test_uninstrument_connection(self, mock_connect):
Expand Down

0 comments on commit 089c90a

Please sign in to comment.