Changeset 6641 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 28 Aug 2011, 08:33:12 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6638 r6641 240 240 self.assertEqual(self.browser.headers['Status'], '200 Ok') 241 241 self.assertEqual(self.browser.url, self.history_student_path) 242 self.assertMatches('...Student admitted by system...', self.browser.contents)242 self.assertMatches('...Student admitted by zope.mgr...', self.browser.contents) 243 243 244 244 return -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_container.py
r6633 r6641 18 18 """ 19 19 import unittest 20 import tempfile 21 import shutil 20 22 from zope.interface.verify import verifyClass, verifyObject 21 23 from zope.component.interfaces import IFactory 22 from zope.app.testing.functional import FunctionalTestCase 24 from zope.component.hooks import setSite 25 from waeup.sirp.app import University 23 26 from waeup.sirp.students.interfaces import ( 24 27 IStudentsContainer, … … 27 30 StudentsContainer, 28 31 ) 29 from waeup.sirp.testing import FunctionalLayer 32 from waeup.sirp.testing import ( 33 FunctionalLayer, FunctionalTestCase, get_all_loggers, remove_new_loggers, 34 remove_logger) 30 35 31 class StudentsContainerTestCase(unittest.TestCase): 36 class StudentsContainerTestCase(FunctionalTestCase): 37 38 layer = FunctionalLayer 39 40 def setUp(self): 41 super(StudentsContainerTestCase, self).setUp() 42 remove_logger('waeup.sirp.app.students') 43 self.old_loggers = get_all_loggers() 44 # Setup a sample site for each test 45 46 # Prepopulate the ZODB... 47 app = University() 48 self.getRootFolder()['app'] = app 49 self.app = self.getRootFolder()['app'] 50 setSite(self.app) 51 52 self.dc_root = tempfile.mkdtemp() 53 app['datacenter'].setStoragePath(self.dc_root) 54 return 55 56 def tearDown(self): 57 super(StudentsContainerTestCase, self).tearDown() 58 remove_new_loggers(self.old_loggers) 59 shutil.rmtree(self.dc_root) 60 return 32 61 33 62 def test_interfaces(self): … … 50 79 self.assertRaises( 51 80 NotImplementedError, container.clear) 81 82 def test_logger(self): 83 # We can get a logger from root 84 logger = self.app['students'].logger 85 assert logger is not None 86 assert logger.name == 'waeup.sirp.app.students' 87 handlers = logger.handlers 88 assert len(handlers) == 1 89 filename = logger.handlers[0].baseFilename 90 assert filename.endswith('students.log') 91 assert filename.startswith(self.dc_root) 92 93 def test_logger_multiple(self): 94 # Make sure the logger is still working after 2nd call 95 # First time we call it, it might be registered 96 logger = self.app['students'].logger 97 # At second call the already registered logger should be returned 98 logger = self.app['students'].logger 99 assert logger is not None 100 assert logger.name == 'waeup.sirp.app.students' 101 handlers = logger.handlers 102 assert len(handlers) == 1 103 filename = logger.handlers[0].baseFilename 104 assert filename.endswith('students.log') 105 assert filename.startswith(self.dc_root)
Note: See TracChangeset for help on using the changeset viewer.