@@ -19,27 +19,6 @@ def __init__(self, channel):
1919
2020
2121class TestGrpcClient (unittest .TestCase ):
22- def test_create_client_insecure_channel (self ):
23- with patch ("azurefunctions.extensions.bindings.servicebus.grpcClient.grpc.insecure_channel" ) as mock_insecure : # noqa
24- fake_channel = MagicMock ()
25- mock_insecure .return_value = fake_channel
26-
27- client = GrpcClientFactory .create_client (
28- service_stub = DummyStub ,
29- address = "localhost:1234" ,
30- grpc_max_message_length = 1024 ,
31- secure = False ,
32- )
33-
34- mock_insecure .assert_called_once ()
35- args , kwargs = mock_insecure .call_args
36- assert args [0 ] == "localhost:1234"
37- assert ("grpc.max_send_message_length" , 1024 ) in kwargs ["options" ]
38- assert ("grpc.max_receive_message_length" , 1024 ) in kwargs ["options" ]
39-
40- assert isinstance (client , DummyStub )
41- assert client ._channel == fake_channel
42-
4322 def test_create_client_secure_channel_with_root_certs (self ):
4423 with (patch ("azurefunctions.extensions.bindings.servicebus.grpcClient.grpc.secure_channel" ) as mock_secure , # noqa
4524 patch ("azurefunctions.extensions.bindings.servicebus.grpcClient.grpc.ssl_channel_credentials" ) as mock_creds ): # noqa
@@ -52,7 +31,6 @@ def test_create_client_secure_channel_with_root_certs(self):
5231 service_stub = DummyStub ,
5332 address = "securehost:9999" ,
5433 grpc_max_message_length = 2048 ,
55- secure = True ,
5634 root_certificates = b"fakecerts" ,
5735 )
5836
@@ -67,21 +45,6 @@ def test_create_client_secure_channel_with_root_certs(self):
6745 assert isinstance (client , DummyStub )
6846 assert client ._channel == fake_channel
6947
70- @patch ("azurefunctions.extensions.bindings.servicebus.grpcClient."
71- "grpc.insecure_channel" )
72- def test_create_client_raises_on_insecure_channel_failure (self ,
73- mock_insecure_channel ):
74- # Arrange: force grpc.insecure_channel to throw
75- mock_insecure_channel .side_effect = RuntimeError ("connection failed" )
76-
77- # Act + Assert
78- with self .assertRaises (GrpcChannelError ) as ctx :
79- GrpcClientFactory .create_client (DummyStub , "localhost:1234" , secure = False )
80-
81- # Ensure exception contains useful context
82- self .assertIn ("Failed to create gRPC channel" , str (ctx .exception ))
83- self .assertIn ("localhost:1234" , str (ctx .exception ))
84-
8548 @patch ("azurefunctions.extensions.bindings.servicebus.grpcClient."
8649 "grpc.secure_channel" )
8750 @patch ("azurefunctions.extensions.bindings.servicebus.grpcClient."
@@ -96,7 +59,6 @@ def test_create_client_raises_on_secure_channel_failure(self,
9659 with self .assertRaises (GrpcChannelError ) as ctx :
9760 GrpcClientFactory .create_client (DummyStub ,
9861 "localhost:5678" ,
99- secure = True ,
10062 root_certificates = b"dummy" )
10163
10264 self .assertIn ("Failed to create gRPC channel" , str (ctx .exception ))
0 commit comments