def test_create_context(self): # Setup Expected Response name = 'name3373707' lifespan_count = 1178775510 expected_response = {'name': name, 'lifespan_count': lifespan_count} expected_response = context_pb2.Context(**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.ContextsClient() # Setup Request parent = client.session_path('[PROJECT]', '[SESSION]') context = {} response = client.create_context(parent, context) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.CreateContextRequest(parent=parent, context=context) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_context(self): # Setup Expected Response name = "name3373707" lifespan_count = 1178775510 expected_response = {"name": name, "lifespan_count": lifespan_count} expected_response = context_pb2.Context(**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.ContextsClient() # Setup Request parent = "parent-995424086" context = {} response = client.create_context(parent, context) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.CreateContextRequest(parent=parent, context=context) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_context(self): # Setup Expected Response name = 'name3373707' lifespan_count = 1178775510 expected_response = {'name': name, 'lifespan_count': lifespan_count} expected_response = context_pb2.Context(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dialogflow_v2beta1.ContextsClient(channel=channel) # Setup Request context = {} response = client.update_context(context) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.UpdateContextRequest(context=context) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_context(self): # Setup Expected Response name_2 = 'name2-1052831874' lifespan_count = 1178775510 expected_response = {'name': name_2, 'lifespan_count': lifespan_count} expected_response = context_pb2.Context(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dialogflow_v2beta1.ContextsClient(channel=channel) # Setup Request name = client.context_path('[PROJECT]', '[SESSION]', '[CONTEXT]') response = client.get_context(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.GetContextRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_context(self): # Setup Expected Response name_2 = 'name2-1052831874' lifespan_count = 1178775510 expected_response = {'name': name_2, 'lifespan_count': lifespan_count} expected_response = context_pb2.Context(**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.ContextsClient() # Setup Request name = client.context_path('[PROJECT]', '[SESSION]', '[CONTEXT]') response = client.get_context(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.GetContextRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_context(self): # Setup Expected Response name_2 = "name2-1052831874" lifespan_count = 1178775510 expected_response = {"name": name_2, "lifespan_count": lifespan_count} expected_response = context_pb2.Context(**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.ContextsClient() # Setup Request name = "name3373707" response = client.get_context(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = context_pb2.GetContextRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request