예제 #1
0
    def test_update_session_entity_type(self):
        # Setup Expected Response
        name = "name3373707"
        expected_response = {"name": name}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **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.SessionEntityTypesClient()

        # Setup Request
        session_entity_type = {}

        response = client.update_session_entity_type(session_entity_type)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.UpdateSessionEntityTypeRequest(
            session_entity_type=session_entity_type)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #2
0
    def test_get_session_entity_type(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        expected_response = {"name": name_2}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **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.SessionEntityTypesClient()

        # Setup Request
        name = client.session_entity_type_path("[PROJECT]", "[SESSION]",
                                               "[ENTITY_TYPE]")

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

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.GetSessionEntityTypeRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #3
0
    def test_create_session_entity_type(self):
        # Setup Expected Response
        name = 'name3373707'
        expected_response = {'name': name}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **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.SessionEntityTypesClient()

        # Setup Request
        parent = client.session_path('[PROJECT]', '[SESSION]')
        session_entity_type = {}

        response = client.create_session_entity_type(parent,
                                                     session_entity_type)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.CreateSessionEntityTypeRequest(
            parent=parent, session_entity_type=session_entity_type)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_update_session_entity_type(self):
        # Setup Expected Response
        name = 'name3373707'
        expected_response = {'name': name}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **expected_response)

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

        # Setup Request
        session_entity_type = {}

        response = client.update_session_entity_type(session_entity_type)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.UpdateSessionEntityTypeRequest(
            session_entity_type=session_entity_type)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_get_session_entity_type(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        expected_response = {'name': name_2}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **expected_response)

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

        # Setup Request
        name = client.session_entity_type_path('[PROJECT]', '[SESSION]',
                                               '[ENTITY_TYPE]')

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

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.GetSessionEntityTypeRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_session_entity_type(self):
        # Setup Expected Response
        name = 'name3373707'
        expected_response = {'name': name}
        expected_response = session_entity_type_pb2.SessionEntityType(
            **expected_response)

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

        # Setup Request
        parent = client.session_path('[PROJECT]', '[SESSION]')
        session_entity_type = {}

        response = client.create_session_entity_type(parent,
                                                     session_entity_type)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.CreateSessionEntityTypeRequest(
            parent=parent, session_entity_type=session_entity_type)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request