예제 #1
0
    def test_get_notification_channel_descriptor(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        type_ = "type3575610"
        display_name = "displayName1615086568"
        description = "description-1724546052"
        expected_response = {
            "name": name_2,
            "type": type_,
            "display_name": display_name,
            "description": description,
        }
        expected_response = notification_pb2.NotificationChannelDescriptor(
            **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_descriptor_path(
            "[PROJECT]", "[CHANNEL_DESCRIPTOR]")

        response = client.get_notification_channel_descriptor(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = notification_service_pb2.GetNotificationChannelDescriptorRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_notification_channel_descriptor(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        type_ = 'type3575610'
        display_name = 'displayName1615086568'
        description = 'description-1724546052'
        expected_response = {
            'name': name_2,
            'type': type_,
            'display_name': display_name,
            'description': description
        }
        expected_response = notification_pb2.NotificationChannelDescriptor(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        client = monitoring_v3.NotificationChannelServiceClient(
            channel=channel)

        # Setup Request
        name = client.notification_channel_descriptor_path(
            '[PROJECT]', '[CHANNEL_DESCRIPTOR]')

        response = client.get_notification_channel_descriptor(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = notification_service_pb2.GetNotificationChannelDescriptorRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request