[Zope-CVS] CVS: Products/NotifyList/tests - testNotifyList.py:1.3
Shane Hathaway
shane@cvs.zope.org
Tue, 22 Jan 2002 15:55:11 -0500
Update of /cvs-repository/Products/NotifyList/tests
In directory cvs.zope.org:/tmp/cvs-serv9342/tests
Modified Files:
testNotifyList.py
Log Message:
Implemented setting list by text and getting the list of all email addresses.
=== Products/NotifyList/tests/testNotifyList.py 1.2 => 1.3 ===
self.assertEqual(len(notify.listGroupContents(id_group)), 0)
+ def testGetListAsText(self):
+ notify = self.app.site.notify
+ id_shane = notify.addEmail(name='Shane', email='x@y.com')
+ id_tina = notify.addEmail(name='Tina', email='t@y.com')
+ notify.addToList([id_shane, id_tina])
+ text = self.app.site.notify.getListAsText()
+ self.assertEqual(text, 'Shane <x@y.com>\nTina <t@y.com>')
+
+ def testSetListAsText(self):
+ # Set up some addresses
+ notify = self.app.site.notify
+ id_shane = notify.addEmail(name='Shane', email='x@y.com')
+ id_tina = notify.addEmail(name='Tina', email='m@y.com')
+ id_group = notify.addGroup(name='testing')
+ id_other = notify.addGroup(name='Other')
+ text = notify.getListAsText()
+ self.assertEqual(text, '')
+ notify.setListAsText("Shane\nm@y.com\nOther\nz@z.com")
+ # The following tests sorting at the same time.
+ text = notify.getListAsText()
+ self.assertEqual(text,
+ "Other\n"
+ "<z@z.com>\n"
+ "Shane <x@y.com>\n"
+ "Tina <m@y.com>"
+ )
+
+ def testGetEmailsForNotification(self):
+ notify = self.app.site.notify
+ id_shane = notify.addEmail(name='Shane', email='s@h.com')
+ id_tina = notify.addEmail(name='Tina', email='t@h.com')
+ id_group = notify.addGroup(name='Us')
+ id_joe = notify.addEmail(name='Joe', email='j@a.com')
+ id_jane = notify.addEmail(name='Jane', email='j@b.com')
+ notify.addToGroupList(id_group, [id_shane, id_tina])
+ notify.addToList([id_joe, id_group])
+ emails = list(notify.getEmailsForNotification())
+ emails.sort()
+ self.assertEqual(emails, ['j@a.com', 's@h.com', 't@h.com'])
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(NotifyListTests))