Changeset 2610 in products


Ignore:
Timestamp:
Jul 5, 2010 8:53:43 AM (14 years ago)
Author:
mylan
Message:

Added tests for GAuthUtility

File:
1 edited

Legend:

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

    r2609 r2610  
    44#from zope.testing import doctestunit 
    55#from zope.component import testing 
    6 from zope.component import queryUtility 
    7 from zope.component import getSiteManager 
     6from zope.component import queryUtility, queryAdapter 
     7from zope.component import getSiteManager, getGlobalSiteManager 
    88from Testing import ZopeTestCase as ztc 
    99 
     
    1818import quintagroup.gauth 
    1919from quintagroup.gauth.interfaces import IGAuthUtility 
     20from quintagroup.gauth.browser.configlet import IGAuthConfigletSchema 
    2021 
    2122class GauthLayer(PloneSite): 
     
    6970    def testUtility(self): 
    7071        lsm = getSiteManager(self.portal) 
    71         gauth = lsm.queryUtility(IGAuthUtility) 
    72         self.assert_(gauth is not None) 
    73         self.assert_(gauth.gconf is not None) 
     72        gsm = getGlobalSiteManager() 
     73        lgauth = lsm.queryUtility(IGAuthUtility) 
     74        ggauth = gsm.queryUtility(IGAuthUtility) 
     75        self.assertEqual(ggauth, None) 
     76        self.assertNotEqual(lgauth, None) 
     77 
    7478 
    7579class TestConfiglet(FunctionalTestCase): 
     
    100104 
    101105 
     106class TestUtility(FunctionalTestCase): 
     107 
     108    def afterSetUp(self): 
     109        self.loginAsPortalOwner() 
     110        self.addProduct("quintagroup.gauth") 
     111        sm = getSiteManager(self.portal) 
     112        self.gauthutil = sm.queryUtility(IGAuthUtility) 
     113        self.gauthconfiglet = queryAdapter(self.portal, IGAuthConfigletSchema) 
     114 
     115    def testEmail(self): 
     116        self.assertEqual(bool(self.gauthutil.email), False) 
     117        self.gauthconfiglet.gauth_email = "tester@test.com" 
     118        self.assertEqual(self.gauthutil.email, "tester@test.com") 
     119 
     120    def testPassword(self): 
     121        self.assertEqual(bool(self.gauthutil.password), False) 
     122        self.gauthconfiglet.gauth_pass = u"secret" 
     123        self.assertEqual(self.gauthutil.password, "secret") 
     124 
     125 
    102126def test_suite(): 
    103127    from unittest import TestSuite, makeSuite 
     
    105129    suite.addTest(makeSuite(TestInstall)) 
    106130    suite.addTest(makeSuite(TestConfiglet)) 
     131    suite.addTest(makeSuite(TestUtility)) 
    107132    return suite 
    108133 
Note: See TracChangeset for help on using the changeset viewer.