18 lines
865 B
Python
18 lines
865 B
Python
|
|
import random
|
|||
|
|
|
|||
|
|
def generate_test_data(N): #Генерирует N записей с именами User_00000 ... User_N-1
|
|||
|
|
records = [(f"User_{i:05d}", f"+7-999-{i:05d}") for i in range(N)]
|
|||
|
|
|
|||
|
|
records_shuffled = records.copy()
|
|||
|
|
random.shuffle(records_shuffled)
|
|||
|
|
|
|||
|
|
records_sorted = sorted(records, key=lambda x: x[0])
|
|||
|
|
|
|||
|
|
return records, records_shuffled, records_sorted
|
|||
|
|
|
|||
|
|
def get_names_for_operations(records, num_find=100, num_delete=50, num_nonexistent=10): #Подготавливает имена для операций поиска и удаления
|
|||
|
|
existing_names = [name for name, _ in records[:num_find + num_delete]]
|
|||
|
|
names_to_find = existing_names[:num_find] + [f"None_{i}" for i in range(num_nonexistent)]
|
|||
|
|
names_to_delete = existing_names[num_find:num_find + num_delete]
|
|||
|
|
|
|||
|
|
return names_to_find, names_to_delete
|