Пример #1
0
 def test_delete_cookie(self):
     response = BaseResponse()
     response.delete_cookie('foo')
     expected_set_cookie = (
         'Set-Cookie',
         'foo=""; expires=Sun, 01 Jan 2017 00:00:00 GMT; Max-Age=-1')
     self.assertIn(expected_set_cookie, response.headerlist)
Пример #2
0
 def test_set_status(self):
     response = BaseResponse()
     response.status = 200
     self.assertEqual(response.status, '200 OK')
Пример #3
0
 def test_set_cookie_with_secret(self):
     response = BaseResponse()
     response.set_cookie('foo', 'bar', secret='secretkey')
     expected_set_cookie = ('Set-Cookie', 'foo="!VzhGFLGcW+5OMs1s4beLXaqFxAUwgHdWkH5fgapghoI='
                                          '?gASVDwAAAAAAAACMA2Zvb5SMA2JhcpSGlC4="')
     self.assertIn(expected_set_cookie, response.headerlist)
Пример #4
0
 def test_set_cookie_with_expires(self):
     response = BaseResponse()
     response.set_cookie('foo', 'bar', expires=datetime(2017, 1, 1, 0, 0, 0))
     expected_set_cookie = ('Set-Cookie', 'foo=bar; expires=Sun, 01 Jan 2017 00:00:00 GMT')
     self.assertIn(expected_set_cookie, response.headerlist)
Пример #5
0
 def test_set_cookie_with_max_age(self):
     response = BaseResponse()
     response.set_cookie('foo', 'bar', max_age=timedelta(seconds=10))
     expected_set_cookie = ('Set-Cookie', 'foo=bar; Max-Age=10')
     self.assertIn(expected_set_cookie, response.headerlist)
Пример #6
0
 def test_set_cookie(self):
     response = BaseResponse()
     response.set_cookie('foo', 'bar')
     expected_set_cookie = ('Set-Cookie', 'foo=bar')
     self.assertIn(expected_set_cookie, response.headerlist)