def test_trace_integration(self): mock_trace_grpc = mock.Mock() mock_trace_http = mock.Mock() patch_trace_grpc = mock.patch( 'opencensus.ext.google_cloud_clientlibs.trace.trace_grpc', mock_trace_grpc) patch_trace_http = mock.patch( 'opencensus.ext.google_cloud_clientlibs.trace.trace_http', mock_trace_http) with patch_trace_grpc, patch_trace_http: trace.trace_integration() self.assertTrue(mock_trace_grpc.called) self.assertTrue(mock_trace_http.called)
def test_trace_grpc(self): mock_wrap = mock.Mock() mock__helpers = mock.Mock() wrap_result = 'wrap result' mock_wrap.return_value = wrap_result mock_make_secure_channel_func = mock.Mock() mock_make_secure_channel_func.__name__ = 'make_secure_channel' setattr(mock__helpers, 'make_secure_channel', mock_make_secure_channel_func) patch_wrap = mock.patch( 'opencensus.ext.google_cloud_clientlibs.trace' '.wrap_make_secure_channel', mock_wrap) patch__helpers = mock.patch( 'opencensus.ext.google_cloud_clientlibs.trace._helpers', mock__helpers) with patch_wrap, patch__helpers: trace.trace_integration() self.assertEqual( getattr(mock__helpers, 'make_secure_channel'), wrap_result)