def test_get_emails_for_sending(self): all = contact_corresponding.get_isi_fields(test_isi_fake_data_file) assert_equals(len(all), 35) unique = contact_corresponding.get_unique_items(all) assert_equals(len(unique), 31) articles = contact_corresponding.get_filtered_dict(unique, lambda k, v: k == "type" and v == "Article") assert_equals(len(articles), 23) articles_of_months = contact_corresponding.get_filtered_dict( articles, lambda k, v: k == "data_month" and v in ["OCT", "NOV", "FAL"] ) assert_equals(len(articles_of_months), 12) one_row_per_email = contact_corresponding.get_one_row_per_email(articles_of_months) assert_equals(len(one_row_per_email), 14) (first_occurrence, dupes) = contact_corresponding.email_first_occurrence(one_row_per_email, True) assert_equals(len(first_occurrence), 10) assert_equals(len(dupes), 4) (first_occurrence2, dupes2) = contact_corresponding.email_not_in_already_sent(first_occurrence, test_sent_file) assert_equals(len(first_occurrence2), 9) assert_equals(len(dupes2), 1) (first_occurrence3, dupes3) = contact_corresponding.filter_unsubscribe_list(first_occurrence2) assert_equals(len(first_occurrence3), 8) assert_equals(len(dupes3), 1) (first_occurrence4, dupes4) = contact_corresponding.filter_exclude_list(first_occurrence3, test_exclude_file) assert_equals(len(first_occurrence4), 6) assert_equals(len(dupes4), 2)
def test_filter_unsubscribe_list(self): test_data = [ { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Review", "emails": ["*****@*****.**"], }, { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Editorial Material", "emails": ["*****@*****.**"], }, { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Editorial Material", "emails": ["*****@*****.**"], }, { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Article", "emails": ["*****@*****.**"], }, { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Article", "emails": ["*****@*****.**", "*****@*****.**"], }, ] (not_unsubscribe, unsubscribe) = contact_corresponding.filter_unsubscribe_list(test_data) assert_equals(len(not_unsubscribe), 4) assert_equals( unsubscribe, [ { "journal": "Heredity", "volume_issue": "105_6", "month": "DEC", "single_email": "*****@*****.**", "year": "2010", "type": "Editorial Material", "emails": ["*****@*****.**"], } ], )