Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Nov 20, 2024
1 parent 11feaf8 commit ce86c1e
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,7 @@ def test_instrument_connection(self):

@mock.patch("opentelemetry.instrumentation.dbapi.DatabaseApiIntegration")
def test_instrument_connection_kwargs_defaults(self, mock_dbapiint):
connection = mock.Mock()
# Avoid get_attributes failing because can't concatenate mock
connection.database = "-"
dbapi.instrument_connection(self.tracer, connection, "-")
dbapi.instrument_connection(self.tracer, mock.Mock(), "foo")
kwargs = mock_dbapiint.call_args[1]
self.assertEqual(kwargs["connection_attributes"], None)
self.assertEqual(kwargs["version"], "")
Expand All @@ -611,13 +608,10 @@ def test_instrument_connection_kwargs_defaults(self, mock_dbapiint):
def test_instrument_connection_kwargs_provided(self, mock_dbapiint):
mock_tracer_provider = mock.MagicMock()
mock_connect_module = mock.MagicMock()
connection = mock.Mock()
# Avoid get_attributes failing because can't concatenate mock
connection.database = "-"
dbapi.instrument_connection(
self.tracer,
connection,
"-",
mock.Mock(),
"foo",
connection_attributes={"foo": "bar"},
version="test",
tracer_provider=mock_tracer_provider,
Expand All @@ -629,11 +623,11 @@ def test_instrument_connection_kwargs_provided(self, mock_dbapiint):
kwargs = mock_dbapiint.call_args[1]
self.assertEqual(kwargs["connection_attributes"], {"foo": "bar"})
self.assertEqual(kwargs["version"], "test")
self.assertEqual(kwargs["tracer_provider"], mock_tracer_provider)
self.assertIs(kwargs["tracer_provider"], mock_tracer_provider)
self.assertEqual(kwargs["capture_parameters"], True)
self.assertEqual(kwargs["enable_commenter"], True)
self.assertEqual(kwargs["commenter_options"], {"foo": "bar"})
self.assertEqual(kwargs["connect_module"], mock_connect_module)
self.assertIs(kwargs["connect_module"], mock_connect_module)

def test_uninstrument_connection(self):
connection = mock.Mock()
Expand Down

0 comments on commit ce86c1e

Please sign in to comment.