def test_update_exclusion(self): # Setup Expected Response name_2 = "name2-1052831874" description = "description-1724546052" filter_ = "filter-1274492040" disabled = True expected_response = { "name": name_2, "description": description, "filter": filter_, "disabled": disabled, } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request name = client.exclusion_path("[PROJECT]", "[EXCLUSION]") exclusion = {} update_mask = {} response = client.update_exclusion(name, exclusion, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateExclusionRequest( name=name, exclusion=exclusion, update_mask=update_mask) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_exclusion(self): # Setup Expected Response name = "name3373707" description = "description-1724546052" filter_ = "filter-1274492040" disabled = True expected_response = { "name": name, "description": description, "filter": filter_, "disabled": disabled, } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request parent = client.project_path("[PROJECT]") exclusion = {} response = client.create_exclusion(parent, exclusion) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.CreateExclusionRequest( parent=parent, exclusion=exclusion) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_exclusion(self): # Setup Expected Response name_2 = 'name2-1052831874' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name_2, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') exclusion = {} update_mask = {} response = client.update_exclusion(name, exclusion, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateExclusionRequest( name=name, exclusion=exclusion, update_mask=update_mask) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_exclusion(self): # Setup Expected Response name_2 = 'name2-1052831874' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name_2, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') response = client.get_exclusion(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.GetExclusionRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_exclusion(self): # Setup Expected Response name = 'name3373707' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') exclusion = {} response = client.create_exclusion(parent, exclusion) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.CreateExclusionRequest( parent=parent, exclusion=exclusion) actual_request = channel.requests[0][1] assert expected_request == actual_request