Commits

Robert Brewer committed d286a19

New test for session_filter.on_create_session.

Comments (0)

Files changed (1)

cherrypy/test/test_session_filter.py

             cherrypy.session.delete() 
             sessionfilter.expire() 
             return "done" 
- 	delete.exposed = True
+        delete.exposed = True
         
+        def oncreate(self):
+            return repr(cherrypy.request.onsessdata)
+        oncreate.exposed = True
+    
+    def Session_new(*args, **kwargs):
+        cherrypy.request.onsessdata = (args, kwargs)
+    
     cherrypy.root = Root()
     cherrypy.config.update({
             'server.log_to_screen': False,
             'session_filter.storage_path' : localDir,
             'session_filter.timeout': 0.017,
             'session_filter.clean_up_delay': 0.017,
+            'session_filter.on_create_session': Session_new,
     })
 
 import helper
         f = lambda: [x for x in os.listdir(localDir) if x.startswith('session-')]
         self.assertNotEqual(f(), [])
 
+        # Test on_create_session
+        self.getPage("/oncreate")
+        # example response: "(({'_id': 'b7a7216a5335726dd4c0d6224f5f4ca9f5969dc6'},), {})"
+        self.assert_(self.body.startswith("(({'_id': '"))
+        
         # Clean up session files
         for fname in os.listdir(localDir):
             if fname.startswith('session-'):