def test_get_stored_info_type(self): # Setup Expected Response name_2 = "name2-1052831874" expected_response = {"name": name_2} expected_response = dlp_pb2.StoredInfoType(**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 = dlp_v2.DlpServiceClient() # Setup Request name = client.organization_stored_info_type_path( "[ORGANIZATION]", "[STORED_INFO_TYPE]" ) response = client.get_stored_info_type(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.GetStoredInfoTypeRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_stored_info_type(self): # Setup Expected Response name = 'name3373707' expected_response = {'name': name} expected_response = dlp_pb2.StoredInfoType(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dlp_v2.DlpServiceClient(channel=channel) # Setup Request parent = client.organization_path('[ORGANIZATION]') response = client.create_stored_info_type(parent) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.CreateStoredInfoTypeRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_stored_info_type(self): # Setup Expected Response name_2 = 'name2-1052831874' expected_response = {'name': name_2} expected_response = dlp_pb2.StoredInfoType(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = dlp_v2.DlpServiceClient(channel=channel) # Setup Request name = client.organization_stored_info_type_path( '[ORGANIZATION]', '[STORED_INFO_TYPE]') response = client.get_stored_info_type(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.GetStoredInfoTypeRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_stored_info_type(self): # Setup Expected Response name = 'name3373707' expected_response = {'name': name} expected_response = dlp_pb2.StoredInfoType(**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 = dlp_v2.DlpServiceClient() # Setup Request parent = client.organization_path('[ORGANIZATION]') response = client.create_stored_info_type(parent) assert expected_response == response assert len(channel.requests) == 1 expected_request = dlp_pb2.CreateStoredInfoTypeRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request