Changeset 6399 for main/waeup.sirp/trunk/src/waeup/sirp/utils/tests
- Timestamp:
- 17 Jun 2011, 15:06:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_logger.py
r6371 r6399 26 26 import tempfile 27 27 from zope.app.testing.functional import FunctionalTestCase 28 from zope.component import queryUtility 28 29 from zope.component.hooks import setSite, clearSite 29 30 from zope.interface.verify import verifyClass, verifyObject … … 31 32 from waeup.sirp.testing import FunctionalLayer, doctestsuite_for_module 32 33 from waeup.sirp.utils.logger import ( 33 ISiteLoggers, ILogger, SiteLoggers, WAeUPLogger) 34 35 class FakeDatacenter(object): 36 def __init__(self): 37 self.storage = None 38 39 class FakeSite(dict): 40 def __init__(self): 41 super(FakeSite, self).__init__() 42 self.__name__ = None 43 self['datacenter'] = FakeDatacenter() 44 34 ISiteLoggers, ILogger, SiteLoggers, WAeUPLogger, SiteLoggersRepository) 45 35 46 36 class SiteLoggersTests(FunctionalTestCase): … … 61 51 62 52 self.workdir = tempfile.mkdtemp() 53 SiteLoggersRepository.clear() 63 54 return 64 55 … … 100 91 loggers.unregister('sample') 101 92 self.assertEqual(loggers._loggers, {}) 93 94 def test_utility_no_site(self): 95 # make sure we get loggers even if no site is defined/set 96 util = queryUtility(ISiteLoggers) 97 loggers = util.getLoggers() 98 assert util is not None 99 assert loggers is not None 100 assert None in SiteLoggersRepository.keys() 101 102 def test_utility(self): 103 # make sute we get loggers for a certain site 104 setSite(self.app) 105 util = queryUtility(ISiteLoggers) 106 loggers = util.getLoggers() 107 assert util is not None 108 assert loggers is not None 109 assert self.app in SiteLoggersRepository.keys() 110 111 def test_utility_multiple(self): 112 # make sure we get the same loggers for same site 113 setSite(self.app) 114 self.assertEqual(SiteLoggersRepository.keys(), []) 115 util = queryUtility(ISiteLoggers) 116 loggers1 = util.getLoggers() 117 loggers2 = util.getLoggers() 118 assert loggers1 is loggers2 119 120 def test_utility_given_site(self): 121 # make sure a passed site is respected 122 util = queryUtility(ISiteLoggers) 123 loggers = util.getLoggers(site=self.app) 124 assert loggers is not None 125 assert self.app in SiteLoggersRepository.keys() 102 126 103 127 class LoggerTests(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.