source: products/ShortMessage/tags/0.1.3/tests/testSm.py @ 1591

Last change on this file since 1591 was 1, checked in by myroslav, 16 years ago

Building directory structure

File size: 2.3 KB
Line 
1from Testing import ZopeTestCase
2from Products.Archetypes.tests import ArchetypesTestCase
3from Products.CMFCore.utils import getToolByName
4from AccessControl.SecurityManagement import newSecurityManager
5from AccessControl.SecurityManagement import noSecurityManager
6from Products.PloneTestCase.setup import setupPloneSite
7
8ZopeTestCase.installProduct('ShortMessage')
9ZopeTestCase.installProduct('CMFMember')
10ZopeTestCase.installProduct('PloneSMSCommunicator')
11from Products.ShortMessage import ShortMessage
12import time
13
14tests=[]
15PRODUCTS=('ShortMessage', 'CMFMember', 'PloneSMSCommunicator')
16
17class TestShortMessage(ArchetypesTestCase.ArcheSiteTestCase):
18
19    def createManager(self, portal):
20        acl_users = portal.acl_users
21        return acl_users._doAddUser('PortalManager', '', ['Manager'], (), (), )
22
23    def installProducts(self, portal):
24        #create manager user
25        self.createManager(portal)
26        user = portal.acl_users.getUserById('PortalManager')
27        #login as manager
28        newSecurityManager(None, user)
29        #install products
30        qi = getToolByName(portal, 'portal_quickinstaller')
31        for product in PRODUCTS:
32            qi.installProduct(product)
33        #log out
34        noSecurityManager()
35
36    def afterSetUp(self):
37
38        #get Portal and acl_users
39        portal = self.portal
40        acl_users = portal.acl_users
41        self.installProducts(portal)
42        #create ShortMessage object
43        us = acl_users.getUserById('PortalManager')
44        newSecurityManager(None, us)
45        self.folder.invokeFactory(type_name='ShortMessage', id='sms')
46        noSecurityManager()
47
48
49    def test_sender(self):
50        self.folder.sms.setSender('+380979312198')
51        self.assertEqual(self.folder.sms.getSender(), '+380979312198')
52
53    def test_recipient(self):
54        self.folder.sms.setRecipient('g1')
55        self.assertEqual(self.folder.sms.getRecipient(), 'g1')
56
57    def test_body(self):
58        self.folder.sms.setBody('hello Taras this is text message')
59        self.assertEqual(self.folder.sms.getBody(), 'hello Taras this is text message')
60
61tests.append(TestShortMessage)
62
63def test_suite():
64    from unittest import TestSuite, makeSuite
65    suite = TestSuite()
66    suite.addTest(makeSuite(TestShortMessage))
67    return suite
68
69if __name__ == '__main__':
70    framework()
Note: See TracBrowser for help on using the repository browser.