• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 19. Events and Subscribers > Step 3: Testing the Adapter

Step 3: Testing the Adapter

The MailSubscriptions tests are as straightforward as the implementation. In the doc string of the MailSubscriptions class, add the following documented testing code:

01 Verify the interface implementation
02 
03 >>> from zope.interface.verify import verifyClass
04 >>> verifyClass(IMailSubscriptions, MailSubscriptions)
05 True
06 
07 Create a subscription instance of a message
08 
09 >>> msg = Message()
10 >>> sub = MailSubscriptions(msg)
11 
12 Verify that we have initially no subscriptions and then add some.
13 
14 >>> sub.getSubscriptions()
15 ()
16 >>> sub.addSubscriptions(('foo@bar.com',))
17 >>> sub.getSubscriptions()
18 ('foo@bar.com',)
19 >>> sub.addSubscriptions(('blah@bar.com',))
20 >>> sub.getSubscriptions()
21 ('foo@bar.com', 'blah@bar.com')
22 >>> sub.addSubscriptions(('doh@bar.com',))
23 >>> sub.getSubscriptions()
24 ('foo@bar.com', 'blah@bar.com', 'doh@bar.com')
25 
26 Now let's also check that we can remove entries.
27 
28 >>> sub.removeSubscriptions(('foo@bar.com',))
29 >>> sub.getSubscriptions()
30 ('blah@bar.com', 'doh@bar.com')


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint