def test_list_session_entity_types(self):
        # Setup Expected Response
        next_page_token = ''
        session_entity_types_element = {}
        session_entity_types = [session_entity_types_element]
        expected_response = {
            'next_page_token': next_page_token,
            'session_entity_types': session_entity_types
        }
        expected_response = session_entity_type_pb2.ListSessionEntityTypesResponse(
            **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]')

        paged_list_response = client.list_session_entity_types(parent)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.session_entity_types[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.ListSessionEntityTypesRequest(
            parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #2
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
Пример #3
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
Пример #4
0
    def test_list_session_entity_types(self):
        # Setup Expected Response
        next_page_token = ""
        session_entity_types_element = {}
        session_entity_types = [session_entity_types_element]
        expected_response = {
            "next_page_token": next_page_token,
            "session_entity_types": session_entity_types,
        }
        expected_response = session_entity_type_pb2.ListSessionEntityTypesResponse(
            **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]")

        paged_list_response = client.list_session_entity_types(parent)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.session_entity_types[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.ListSessionEntityTypesRequest(
            parent=parent)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #5
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
    def test_update_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        client = dialogflow_v2beta1.SessionEntityTypesClient(channel=channel)

        # Setup request
        session_entity_type = {}

        with pytest.raises(CustomException):
            client.update_session_entity_type(session_entity_type)
    def test_list_session_entity_types_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        client = dialogflow_v2beta1.SessionEntityTypesClient(channel=channel)

        # Setup request
        parent = client.session_path('[PROJECT]', '[SESSION]')

        paged_list_response = client.list_session_entity_types(parent)
        with pytest.raises(CustomException):
            list(paged_list_response)
    def test_delete_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        client = dialogflow_v2beta1.SessionEntityTypesClient(channel=channel)

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

        with pytest.raises(CustomException):
            client.delete_session_entity_type(name)
    def test_create_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        client = dialogflow_v2beta1.SessionEntityTypesClient(channel=channel)

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

        with pytest.raises(CustomException):
            client.create_session_entity_type(parent, session_entity_type)
Пример #10
0
    def test_list_session_entity_types_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        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]")

        paged_list_response = client.list_session_entity_types(parent)
        with pytest.raises(CustomException):
            list(paged_list_response)
Пример #11
0
    def test_update_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        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 = {}

        with pytest.raises(CustomException):
            client.update_session_entity_type(session_entity_type)
Пример #12
0
    def test_delete_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        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]")

        with pytest.raises(CustomException):
            client.delete_session_entity_type(name)
Пример #13
0
    def test_create_session_entity_type_exception(self):
        # Mock the API response
        channel = ChannelStub(responses=[CustomException()])
        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 = {}

        with pytest.raises(CustomException):
            client.create_session_entity_type(parent, session_entity_type)
    def test_delete_session_entity_type(self):
        channel = ChannelStub()
        client = dialogflow_v2beta1.SessionEntityTypesClient(channel=channel)

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

        client.delete_session_entity_type(name)

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.DeleteSessionEntityTypeRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Пример #15
0
    def test_delete_session_entity_type(self):
        channel = ChannelStub()
        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]")

        client.delete_session_entity_type(name)

        assert len(channel.requests) == 1
        expected_request = session_entity_type_pb2.DeleteSessionEntityTypeRequest(
            name=name)
        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