Exemple #1
0
 def afterSetUp(self):
     """
     """
     super(TestShopMailAddresses, self).afterSetUp()
     self.addresses = IMailAddresses(self.shop)
Exemple #2
0
class TestShopMailAddresses(EasyShopTestCase):
    """
    """
    def afterSetUp(self):
        """
        """
        super(TestShopMailAddresses, self).afterSetUp()
        self.addresses = IMailAddresses(self.shop)

    def testGetAddresses1(self):
        """No information entered.
        """        
        sender = self.addresses.getSender()
        self.assertEqual(sender, None)
        
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ())

        
    def testGetAddresses2(self):
        """Information entered in portal. Note: Portal has just one email 
        address which is used for sender and receiver.
        """
        utool = getToolByName(self.shop, "portal_url")
        portal = utool.getPortalObject()
                
        mail = IMailSchema(portal)
        
        # Just address is entered
        mail.set_email_from_address("*****@*****.**")
        
        sender = self.addresses.getSender()
        self.assertEqual(sender, "Site Administrator <*****@*****.**>")

        # receiver is same as sender
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("Site Administrator <*****@*****.**>",))
        
        # Address and name is entered
        mail.set_email_from_name("John Doe")
        
        sender = self.addresses.getSender()
        self.assertEqual(sender, "John Doe <*****@*****.**>")

        # receiver is same as sender
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("John Doe <*****@*****.**>",))
        
    def testGetAddresses3(self):
        """Information entered in shop.
        """
        self.shop.setMailFromAddress("*****@*****.**")
        
        sender = self.addresses.getSender()
        self.assertEqual(sender, "Site Administrator <*****@*****.**>")
        
        # Just sender is set, hence receiver is same as sender
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("Site Administrator <*****@*****.**>",))
        
        # Name and address is set
        self.shop.setMailFromName("John Doe")
        
        sender = self.addresses.getSender()
        self.assertEqual(sender, "John Doe <*****@*****.**>")

        # Just sender is set, hence receiver is same as sender
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("John Doe <*****@*****.**>",))

        # Receivers set
        self.shop.setMailTo(["Jane Doe <*****@*****.**>"])

        sender = self.addresses.getSender()
        self.assertEqual(sender, "John Doe <*****@*****.**>")
        
        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("Jane Doe <*****@*****.**>",))

        # More receivers set
        self.shop.setMailTo(["Jane Doe <*****@*****.**>", "*****@*****.**"])

        receivers = self.addresses.getReceivers()
        self.assertEqual(receivers, ("Jane Doe <*****@*****.**>", "*****@*****.**"))