def test_get_contacts(self): '''get_recipients(contacts=[...]) should return the requested contacts' adresses''' contacts = conf.CONTACTS.keys() expected = conf.CONTACTS.values() self._check_recipients(expected, get_recipients(contacts=contacts)) contacts = list(contacts)[:1] + list(contacts)[-1:] expected = list(expected)[:1] + list(expected)[-1:] self._check_recipients(expected, get_recipients(contacts=contacts))
def test_no_duplicates(self): '''get_recipients() should return no duplicates''' expected = ['*****@*****.**'] self._check_recipients(expected, get_recipients(arbs=['*****@*****.**', '*****@*****.**', '*****@*****.**']) ) expected = ['*****@*****.**'] self._check_recipients(expected, get_recipients(contacts=['bob', 'bob', 'bob', 'bob']) )
def test_get_group_plus_arbitrary(self): '''get_recipients(grps=[...], arbs=[...]''' expected = [conf.CONTACTS[c] for c in conf.GROUPS['work']] arb_args = ['*****@*****.**', '*****@*****.**'] expected += arb_args self._check_recipients(expected, get_recipients(grps=['work'], arbs=arb_args))
def test_get_group_plus_contacts(self): '''get_recipients(grps=[...], contacts=[...]''' expected = [conf.CONTACTS[c] for c in conf.GROUPS['pals']] grp_args = expected[:] c_args = ['blondie'] for c in c_args: expected.append(conf.CONTACTS[c]) self._check_recipients(expected, get_recipients(grps=['pals'], contacts=c_args))
def test_get_arbs(self): '''get_recipients(arbs=[...]) should return only the provided mail adresses''' expected = [ '*****@*****.**', '*****@*****.**', '*****@*****.**' ] self._check_recipients(expected, get_recipients(arbs=expected))
def test_get_multiple_groups(self): '''get_recipients([...]) should return all the requested groups' adresses as a list''' inp = [] expected = [] for grp, c_list in conf.GROUPS.items(): inp.append(grp) expected += [conf.CONTACTS[c] for c in c_list] expected = list(set(expected)) self._check_recipients(expected, get_recipients(inp))
def test_get_contacts_plus_arbitrary(self): '''get_recipients(contacts=[...], arbs=[...]''' c_args = ['marylou', 'vader', 'blondie'] arb_args = ['*****@*****.**', '*****@*****.**'] expected = [conf.CONTACTS['marylou'], conf.CONTACTS['vader'], conf.CONTACTS['blondie'] ] expected += arb_args self._check_recipients(expected, get_recipients(contacts=c_args, arbs=arb_args))
def test_get_all_opts(self): '''get_recipients(grups=[...], contacts=[...], arbs=[...])''' grp_args = ['work'] expected = [conf.CONTACTS[c] for c in conf.GROUPS['work']] c_args = ['vader'] expected += [conf.CONTACTS[c] for c in c_args] arb_args = ['*****@*****.**', '*****@*****.**'] expected += arb_args self._check_recipients(expected, get_recipients(grps=grp_args, contacts=c_args, arbs=arb_args))
def test_get_group(self): '''get_recipients([grp]) should return the requested group's adresses as a list''' for grp, c_list in conf.GROUPS.items(): expected = [conf.CONTACTS[c] for c in c_list] self._check_recipients(expected, get_recipients([grp]))
def test_no_input(self): '''get_recipients() (No args) should return an empty list''' self.assertEqual([], get_recipients())