Beispiel #1
0
    def test_update_knowledge_base(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        language_code = "languageCode-412800396"
        expected_response = {
            "name": name,
            "display_name": display_name,
            "language_code": language_code,
        }
        expected_response = knowledge_base_pb2.KnowledgeBase(
            **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 = dialogflow_v2beta1.KnowledgeBasesClient()

        # Setup Request
        knowledge_base = {}

        response = client.update_knowledge_base(knowledge_base)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = knowledge_base_pb2.UpdateKnowledgeBaseRequest(
            knowledge_base=knowledge_base)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #2
0
    def test_create_knowledge_base(self):
        # Setup Expected Response
        name = 'name3373707'
        display_name = 'displayName1615086568'
        expected_response = {'name': name, 'display_name': display_name}
        expected_response = knowledge_base_pb2.KnowledgeBase(
            **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 = dialogflow_v2beta1.KnowledgeBasesClient()

        # Setup Request
        parent = client.project_path('[PROJECT]')
        knowledge_base = {}

        response = client.create_knowledge_base(parent, knowledge_base)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = knowledge_base_pb2.CreateKnowledgeBaseRequest(
            parent=parent, knowledge_base=knowledge_base)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #3
0
    def test_get_knowledge_base(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        language_code = "languageCode-412800396"
        expected_response = {
            "name": name_2,
            "display_name": display_name,
            "language_code": language_code,
        }
        expected_response = knowledge_base_pb2.KnowledgeBase(
            **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 = dialogflow_v2beta1.KnowledgeBasesClient()

        # Setup Request
        name = client.knowledge_base_path("[PROJECT]", "[KNOWLEDGE_BASE]")

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

        assert len(channel.requests) == 1
        expected_request = knowledge_base_pb2.GetKnowledgeBaseRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Beispiel #4
0
    def test_get_knowledge_base(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        expected_response = {'name': name_2, 'display_name': display_name}
        expected_response = knowledge_base_pb2.KnowledgeBase(
            **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 = dialogflow_v2beta1.KnowledgeBasesClient()

        # Setup Request
        name = client.knowledge_base_path('[PROJECT]', '[KNOWLEDGE_BASE]')

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

        assert len(channel.requests) == 1
        expected_request = knowledge_base_pb2.GetKnowledgeBaseRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_knowledge_base(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        display_name = 'displayName1615086568'
        expected_response = {'name': name_2, 'display_name': display_name}
        expected_response = knowledge_base_pb2.KnowledgeBase(
            **expected_response)

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

        # Setup Request
        name = client.knowledge_base_path('[PROJECT]', '[KNOWLEDGE_BASE]')

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

        assert len(channel.requests) == 1
        expected_request = knowledge_base_pb2.GetKnowledgeBaseRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request