Skip to content

Commit 385ea6c

Browse files
Add test
1 parent d56eb21 commit 385ea6c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,33 @@ def test_executemany_mysqlclient_integration_comment(
364364
r"Select 1 /\*db_driver='MySQLdb%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',mysql_client_version='123',traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
365365
)
366366

367+
def test_executemany_pymysql_integration_comment(self):
368+
connect_module = mock.MagicMock()
369+
connect_module.__name__ = "pymysql"
370+
connect_module.__version__ = "1.2.3"
371+
connect_module.apilevel = 123
372+
connect_module.threadsafety = 123
373+
connect_module.paramstyle = "test"
374+
connect_module.get_client_info = mock.MagicMock(return_value="123")
375+
376+
db_integration = dbapi.DatabaseApiIntegration(
377+
"testname",
378+
"mysql",
379+
enable_commenter=True,
380+
commenter_options={"db_driver": True, "dbapi_level": False},
381+
connect_module=connect_module,
382+
)
383+
384+
mock_connection = db_integration.wrapped_connection(
385+
mock_connect, {}, {}
386+
)
387+
cursor = mock_connection.cursor()
388+
cursor.executemany("Select 1;")
389+
self.assertRegex(
390+
cursor.query,
391+
r"Select 1 /\*db_driver='pymysql%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',mysql_client_version='123',traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
392+
)
393+
367394
def test_executemany_flask_integration_comment(self):
368395
connect_module = mock.MagicMock()
369396
connect_module.__name__ = "test"

0 commit comments

Comments
 (0)