Пример #1
0
    def test_to_string(self):
        cookie = Cookie('foo', 'bar', 1, '/', 'example.com', True)
        self.assertEquals(
            'foo=bar; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=example.com; secure; httponly',
            str(cookie))

        cookie = Cookie('foo', '', 1, '/admin/', 'example.com')
        self.assertEqual(
            'foo=deleted; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=/admin/; domain=example.com; httponly',
            str(cookie))

        cookie = Cookie('foo', 'bar', 0, '/', '')
        self.assertEqual('foo=bar; path=/; httponly', str(cookie))
Пример #2
0
    def test_cookie_is_cleared(self):
        cookie = Cookie('foo', 'bar', int(round(time.time())) - 20)

        self.assertTrue(cookie.is_cleared())
Пример #3
0
    def test_is_http_only(self):
        cookie = Cookie('foo', 'bar', 3600, '/', 'example.com', False, True)

        self.assertTrue(cookie.is_http_only())
Пример #4
0
    def test_cookie_is_not_cleared(self):
        cookie = Cookie('foo', 'bar', int(round(time.time())) + 3600 * 24)

        self.assertFalse(cookie.is_cleared())
Пример #5
0
    def test_is_secure(self):
        cookie = Cookie('foo', 'bar', 3600, '/', 'example.com', True)

        self.assertTrue(cookie.is_secure())
Пример #6
0
    def test_get_domain(self):
        cookie = Cookie('foo', 'bar', 3600, '/', 'example.com')

        self.assertEqual('example.com', cookie.get_domain())
Пример #7
0
    def test_get_expires_time(self):
        cookie = Cookie('foo', 'bar', 3600)

        self.assertEqual(3600, cookie.get_expires_time())
Пример #8
0
    def test_get_path(self):
        cookie = Cookie('foo', 'bar')

        self.assertEqual('/', cookie.get_path())
Пример #9
0
    def test_get_value(self):
        value = 'MyValue'
        cookie = Cookie('MyCookie', value)

        self.assertEqual(value, cookie.get_value())