def test_contacts_with_weight_type(self): c = [ EmailAddress("emailname", "emailaddr"), EmailAddress("emailname", "emailaddr", weight=50), PhoneNumber("phonename", "phonenum"), ] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts(of_type=EmailAddress)), [c[1]])
def test_contacts_with_weight_all(self): c = [ EmailAddress("emailname", "emailaddr"), EmailAddress("emailname", "emailaddr", weight=50), PhoneNumber("phonename", "phonenum"), ] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts(include_all=True)), [c[1], c[0], c[2]])
def test_contacts_having(self): c = [PhoneNumber("phonename", "phonenum", sms_ok=False), PhoneNumber("phonename", "phonenum", sms_ok=True)] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts(sms_ok=True)), [c[1]])
def test_contacts_by_type(self): c = [EmailAddress("emailname", "emailaddr"), PhoneNumber("phonename", "phonenum")] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts(of_type=EmailAddress)), [c[0]])
def test_less_simple_recipient(self): c = [EmailAddress("emailname", "emailaddr"), PhoneNumber("phonename", "phonenum")] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts()), c)
def test_simple_recipient(self): c = [EmailAddress("emailname", "emailaddr")] r = Recipient("recipientname", contacts=c) self.assertEqual(list(r.contacts()), c)
def test_recipient_defaults(self): r = Recipient("recipientname") self.assertEqual(list(r.contacts()), [])