Ticket #1652: patch.diff
| File patch.diff, 2.9 kB (added by mschw, 7 months ago) |
|---|
-
turbogears/identity/tests/test_visit.py
old new 27 27 cherrypy.root = VisitRoot() 28 28 29 29 def tearDown(self): 30 turbogears.startup.stopTurboGears() 30 31 turbogears.config.update({'visit.timeout': self._visit_timeout}) 31 32 turbogears.config.update({'visit.on': self._visit_on}) 32 33 … … 38 39 # the following command shuts down the visit framework properly 39 40 # the test still passes without it, but exceptions are thrown later 40 41 # once nose wants to quit. 41 turbogears.startup.stopTurboGears()42 42 43 43 def test_new_visit(self): 44 44 "Test that we can see a new visit on the server." 45 45 testutil.create_request("/") 46 46 assert turbogears.visit.current().is_new 47 turbogears.startup.stopTurboGears()48 47 49 48 def test_old_visit(self): 50 49 "Test if we can track a visitor over time." … … 53 52 morsel = cherrypy.response.simple_cookie[self.cookie_name] 54 53 testutil.create_request("/", headers=cookie_header(morsel)) 55 54 assert not turbogears.visit.current().is_new 56 turbogears.startup.stopTurboGears()57 55 58 56 def test_cookie_expires(self): 59 57 "Test if the visit timeout mechanism works." … … 67 65 'cookie values should not match' 68 66 assert turbogears.visit.current().is_new, \ 69 67 'this should be a new visit, as the cookie has expired' 70 turbogears.startup.stopTurboGears() 68 69 def test_cookie_re_sent(self): 70 "Test whether the visit cookie is re-sent with new expiry time." 71 testutil.create_request('/') 72 morsel = cherrypy.response.simple_cookie[self.cookie_name] 73 exp1 = time.strptime(morsel['expires'], '%a, %d-%b-%Y %H:%M:%S GMT') 74 # sleep one second to ensure that we get a new expiry time. 75 time.sleep(1) 76 headers = {'Cookie': morsel.output(header='')[1:]} 77 testutil.create_request('/', headers=headers) 78 assert self.cookie_name in cherrypy.response.simple_cookie 79 morsel = cherrypy.response.simple_cookie[self.cookie_name] 80 exp2 = time.strptime(morsel['expires'], '%a, %d-%b-%Y %H:%M:%S GMT') 81 assert exp1 < exp2 -
turbogears/visit/api.py
old new 229 229 if not visit: 230 230 visit_key = self._generate_key() 231 231 visit = _manager.new_visit_with_key(visit_key) 232 self.send_cookie(visit_key)233 232 233 self.send_cookie(visit_key) 234 234 235 set_current(visit) 235 236 236 237 # Inform all the plugins that a request has been made for the current