@@ -85,7 +85,7 @@ def index(req):
8585
8686 def test_session_default_path (self ):
8787 app = Microdot ()
88- session_ext . initialize (app , secret_key = 'some-other-secret' )
88+ Session (app , secret_key = 'some-other-secret' )
8989 client = TestClient (app )
9090
9191 @app .get ('/' )
@@ -100,15 +100,26 @@ def index(req, session):
100100 def child (req , session ):
101101 return str (session .get ('foo' ))
102102
103+ @app .get ('/delete' )
104+ @with_session
105+ def delete (req , session ):
106+ session .delete ()
107+ return ''
108+
103109 res = self ._run (client .get ('/' ))
104110 self .assertEqual (res .status_code , 200 )
105111 res = self ._run (client .get ('/child' ))
106112 self .assertEqual (res .text , 'bar' )
113+ res = self ._run (client .get ('/delete' ))
114+ res = self ._run (client .get ('/child' ))
115+ self .assertEqual (res .text , 'None' )
107116
108117 def test_session_custom_path (self ):
109118 app = Microdot ()
119+ session_ext = Session ()
110120 session_ext .initialize (app , secret_key = 'some-other-secret' ,
111- cookie_options = {'path' : '/child' })
121+ cookie_options = {'path' : '/child' ,
122+ 'http_only' : False })
112123 client = TestClient (app )
113124
114125 @app .get ('/' )
@@ -128,9 +139,20 @@ def child(req, session):
128139 def foo (req , session ):
129140 return str (session .get ('foo' ))
130141
142+ @app .get ('/child/delete' )
143+ @with_session
144+ def delete (req , session ):
145+ session .delete ()
146+ return ''
147+
131148 res = self ._run (client .get ('/child' ))
132149 self .assertEqual (res .status_code , 200 )
133150 res = self ._run (client .get ('/' ))
134151 self .assertEqual (res .text , 'None' )
135152 res = self ._run (client .get ('/child/foo' ))
136153 self .assertEqual (res .text , 'bar' )
154+ res = self ._run (client .get ('/child/delete' ))
155+ res = self ._run (client .get ('/' ))
156+ self .assertEqual (res .text , 'None' )
157+ res = self ._run (client .get ('/child/foo' ))
158+ self .assertEqual (res .text , 'None' )
0 commit comments