I have written code to create a Secret Santa list from a .csv file with groups of names and corresponding emails.
import random
import pandas as pd
def compare(list_of_names, list_of_emails):
zipped_lists = list(zip(list_of_emails, list_of_names))
random.shuffle(zipped_lists) # shuffle list of emails and names
result = []
shuffled_emails = [i[0] for i in zipped_lists]
for i, _ in enumerate(shuffled_emails):
result.append(zipped_lists[i-1][1]) # shift email relatively one position to the right
return list(zip(result, shuffled_emails))
def main():
names = ["John", "Bob", "Alice"]
emails = ["John@gmail.com", "Bob@gmail.com", "Alice@outlook.com"]
print(compare(names,emails))
if __name__ == '__main__':
main()
How can I unit test this code, since I am using random shuffle operations? I am not sure how I could write a test case for the same.