Ignore:
Timestamp:
Jul 2, 2010 12:20:27 PM (14 years ago)
Author:
mylan
Message:

Added test for configlet, fix configlet bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.gauth/trunk/quintagroup/gauth/tests.py

    r2607 r2608  
    99from Products.PloneTestCase import PloneTestCase as ptc 
    1010from Products.PloneTestCase.layer import PloneSite 
     11from Products.PloneTestCase.PloneTestCase import portal_owner 
     12from Products.PloneTestCase.PloneTestCase import default_password 
     13 
    1114ptc.setupPloneSite() 
    1215 
     
    6164 
    6265 
     66class TestConfiglet(FunctionalTestCase): 
     67 
     68    def afterSetUp(self): 
     69        self.loginAsPortalOwner() 
     70        self.addProduct("quintagroup.gauth") 
     71        self.basic_auth = portal_owner + ":" + default_password 
     72        self.get_url = self.portal.id+'/@@gauth-controlpanel' 
     73        self.save_url = self.portal.id+'/@@gauth-controlpanel?form.actions.save=1' \ 
     74            '&_authenticator=%s' % self._getauth() 
     75 
     76    def test_presentEmail(self): 
     77        res = self.publish(self.get_url, self.basic_auth).getBody() 
     78        self.assert_(re.match(".*<input\s[^>]*name=\"form.gauth_email\"[^>]*>", res, re.I|re.S)) 
     79 
     80    def test_presentPassword(self): 
     81        res = self.publish(self.get_url, self.basic_auth).getBody() 
     82        self.assert_(re.match(".*<input\s[^>]*name=\"form.gauth_pass\"[^>]*>", res, re.I|re.S)) 
     83 
     84    def test_update(self): 
     85        temail, tpass = "tester@test.com", "secret" 
     86        from quintagroup.gauth.interfaces import IGAuthInterface 
     87        from zope.component import queryUtility 
     88        gauth_util = queryUtility(IGAuthInterface) 
     89        gauth_util.gconf_init(self.portal, self.portal.REQUEST) 
     90        url = self.save_url + '&form.gauth_email='+temail + '&form.gauth_pass='+tpass 
     91        self.publish(url, self.basic_auth) 
     92        self.assert_(gauth_util.email == temail) 
     93        self.assert_(gauth_util.password == tpass) 
     94         
     95 
    6396def test_suite(): 
    6497    from unittest import TestSuite, makeSuite 
    6598    suite = TestSuite() 
    6699    suite.addTest(makeSuite(TestInstall)) 
     100    suite.addTest(makeSuite(TestConfiglet)) 
    67101    return suite 
    68102 
Note: See TracChangeset for help on using the changeset viewer.