def test_update_notification_channel(self): # Setup Expected Response type_ = "type3575610" name = "name3373707" display_name = "displayName1615086568" description = "description-1724546052" expected_response = { "type": type_, "name": name, "display_name": display_name, "description": description, } expected_response = notification_pb2.NotificationChannel( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = monitoring_v3.NotificationChannelServiceClient() # Setup Request notification_channel = {} response = client.update_notification_channel(notification_channel) assert expected_response == response assert len(channel.requests) == 1 expected_request = notification_service_pb2.UpdateNotificationChannelRequest( notification_channel=notification_channel) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_notification_channel(self): # Setup Expected Response type_ = "type3575610" name_2 = "name2-1052831874" display_name = "displayName1615086568" description = "description-1724546052" expected_response = { "type": type_, "name": name_2, "display_name": display_name, "description": description, } expected_response = notification_pb2.NotificationChannel( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = monitoring_v3.NotificationChannelServiceClient() # Setup Request name = client.notification_channel_path("[PROJECT]", "[NOTIFICATION_CHANNEL]") response = client.get_notification_channel(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = notification_service_pb2.GetNotificationChannelRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_notification_channel(self): # Setup Expected Response type_ = 'type3575610' name_2 = 'name2-1052831874' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'type': type_, 'name': name_2, 'display_name': display_name, 'description': description } expected_response = notification_pb2.NotificationChannel( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = monitoring_v3.NotificationChannelServiceClient( channel=channel) # Setup Request name = client.notification_channel_path('[PROJECT]', '[NOTIFICATION_CHANNEL]') response = client.get_notification_channel(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = notification_service_pb2.GetNotificationChannelRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_notification_channel(self): # Setup Expected Response type_ = 'type3575610' name = 'name3373707' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'type': type_, 'name': name, 'display_name': display_name, 'description': description } expected_response = notification_pb2.NotificationChannel( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = monitoring_v3.NotificationChannelServiceClient( channel=channel) # Setup Request notification_channel = {} response = client.update_notification_channel(notification_channel) assert expected_response == response assert len(channel.requests) == 1 expected_request = notification_service_pb2.UpdateNotificationChannelRequest( notification_channel=notification_channel) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_notification_channel(self): # Setup Expected Response type_ = 'type3575610' name_2 = 'name2-1052831874' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'type': type_, 'name': name_2, 'display_name': display_name, 'description': description } expected_response = notification_pb2.NotificationChannel( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch('google.api_core.grpc_helpers.create_channel') with patch as create_channel: create_channel.return_value = channel client = monitoring_v3.NotificationChannelServiceClient() # Setup Request name = client.project_path('[PROJECT]') notification_channel = {} response = client.create_notification_channel(name, notification_channel) assert expected_response == response assert len(channel.requests) == 1 expected_request = notification_service_pb2.CreateNotificationChannelRequest( name=name, notification_channel=notification_channel) actual_request = channel.requests[0][1] assert expected_request == actual_request