def test_update_entity_type(self): # Setup Expected Response name = "name3373707" display_name = "displayName1615086568" enable_fuzzy_extraction = True expected_response = { "name": name, "display_name": display_name, "enable_fuzzy_extraction": enable_fuzzy_extraction, } expected_response = entity_type_pb2.EntityType(**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.EntityTypesClient() # Setup Request entity_type = {} response = client.update_entity_type(entity_type) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.UpdateEntityTypeRequest( entity_type=entity_type) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_entity_type(self): # Setup Expected Response name_2 = "name2-1052831874" display_name = "displayName1615086568" enable_fuzzy_extraction = True expected_response = { "name": name_2, "display_name": display_name, "enable_fuzzy_extraction": enable_fuzzy_extraction, } expected_response = entity_type_pb2.EntityType(**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.EntityTypesClient() # Setup Request name = client.entity_type_path("[PROJECT]", "[ENTITY_TYPE]") response = client.get_entity_type(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.GetEntityTypeRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_entity_type(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' expected_response = {'name': name, 'display_name': display_name} expected_response = entity_type_pb2.EntityType(**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.EntityTypesClient() # Setup Request parent = client.project_agent_path('[PROJECT]') entity_type = {} response = client.create_entity_type(parent, entity_type) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.CreateEntityTypeRequest( parent=parent, entity_type=entity_type) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_entity_type(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' expected_response = {'name': name_2, 'display_name': display_name} expected_response = entity_type_pb2.EntityType(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dialogflow_v2beta1.EntityTypesClient(channel=channel) # Setup Request name = client.entity_type_path('[PROJECT]', '[ENTITY_TYPE]') response = client.get_entity_type(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.GetEntityTypeRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_entity_type(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' expected_response = {'name': name, 'display_name': display_name} expected_response = entity_type_pb2.EntityType(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dialogflow_v2beta1.EntityTypesClient(channel=channel) # Setup Request entity_type = {} response = client.update_entity_type(entity_type) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.UpdateEntityTypeRequest( entity_type=entity_type) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_entity_type(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' expected_response = {'name': name_2, 'display_name': display_name} expected_response = entity_type_pb2.EntityType(**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.EntityTypesClient() # Setup Request name = client.entity_type_path('[PROJECT]', '[ENTITY_TYPE]') response = client.get_entity_type(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = entity_type_pb2.GetEntityTypeRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request