|
24 | 24 | from opentelemetry.test.test_base import TestBase |
25 | 25 |
|
26 | 26 |
|
| 27 | +# pylint: disable=too-many-public-methods |
27 | 28 | class TestDBApiIntegration(TestBase): |
28 | 29 | def setUp(self): |
29 | 30 | super().setUp() |
@@ -303,6 +304,59 @@ def test_compatible_build_version_psycopg_psycopg2_libpq(self): |
303 | 304 | r"Select 1 /\*dbapi_threadsafety=123,driver_paramstyle='test',libpq_version=123,traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;", |
304 | 305 | ) |
305 | 306 |
|
| 307 | + def test_executemany_psycopg2_integration_comment(self): |
| 308 | + connect_module = mock.MagicMock() |
| 309 | + connect_module.__name__ = "psycopg2" |
| 310 | + connect_module.__version__ = "1.2.3" |
| 311 | + connect_module.__libpq_version__ = 123 |
| 312 | + connect_module.apilevel = 123 |
| 313 | + connect_module.threadsafety = 123 |
| 314 | + connect_module.paramstyle = "test" |
| 315 | + |
| 316 | + db_integration = dbapi.DatabaseApiIntegration( |
| 317 | + "testname", |
| 318 | + "postgresql", |
| 319 | + enable_commenter=True, |
| 320 | + commenter_options={"db_driver": True, "dbapi_level": False}, |
| 321 | + connect_module=connect_module, |
| 322 | + ) |
| 323 | + mock_connection = db_integration.wrapped_connection( |
| 324 | + mock_connect, {}, {} |
| 325 | + ) |
| 326 | + cursor = mock_connection.cursor() |
| 327 | + cursor.executemany("Select 1;") |
| 328 | + self.assertRegex( |
| 329 | + cursor.query, |
| 330 | + r"Select 1 /\*db_driver='psycopg2%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',libpq_version=123,traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;", |
| 331 | + ) |
| 332 | + |
| 333 | + def test_executemany_psycopg_integration_comment(self): |
| 334 | + connect_module = mock.MagicMock() |
| 335 | + connect_module.__name__ = "psycopg" |
| 336 | + connect_module.__version__ = "1.2.3" |
| 337 | + connect_module.pq = mock.MagicMock() |
| 338 | + connect_module.pq.__build_version__ = 123 |
| 339 | + connect_module.apilevel = 123 |
| 340 | + connect_module.threadsafety = 123 |
| 341 | + connect_module.paramstyle = "test" |
| 342 | + |
| 343 | + db_integration = dbapi.DatabaseApiIntegration( |
| 344 | + "testname", |
| 345 | + "postgresql", |
| 346 | + enable_commenter=True, |
| 347 | + commenter_options={"db_driver": True, "dbapi_level": False}, |
| 348 | + connect_module=connect_module, |
| 349 | + ) |
| 350 | + mock_connection = db_integration.wrapped_connection( |
| 351 | + mock_connect, {}, {} |
| 352 | + ) |
| 353 | + cursor = mock_connection.cursor() |
| 354 | + cursor.executemany("Select 1;") |
| 355 | + self.assertRegex( |
| 356 | + cursor.query, |
| 357 | + r"Select 1 /\*db_driver='psycopg%%3A1.2.3',dbapi_threadsafety=123,driver_paramstyle='test',libpq_version=123,traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;", |
| 358 | + ) |
| 359 | + |
306 | 360 | def test_executemany_mysqlconnector_integration_comment(self): |
307 | 361 | connect_module = mock.MagicMock() |
308 | 362 | connect_module.__name__ = "mysql.connector" |
|
0 commit comments