示例#1
0
 def test_example1(self):
     # Client requests a document, and receives in the response:
     a = ('CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday,'
          ' 09-Nov-99 23:12:40 GMT')
     b = {'customer': Cookie('WILE_E_COYOTE', path='/',
                             expires='Wednesday, 09-Nov-99 23:12:40 GMT')}
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE'
     b = {'customer': Cookie('WILE_E_COYOTE')}
     self.assertEqual(CookieDataType.decode(a), b)
     # Client requests a document, and receives in the response:
     a = 'PART_NUMBER=ROCKET_LAUNCHER_0001; path=/'
     b = {'part_number': Cookie('ROCKET_LAUNCHER_0001', path='/')}
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001'
     b = {'customer': Cookie('WILE_E_COYOTE'),
          'part_number': Cookie('ROCKET_LAUNCHER_0001')}
     self.assertEqual(CookieDataType.decode(a), b)
     # Client receives:
     a = 'SHIPPING=FEDEX; path=/foo'
     b = {'shipping': Cookie('FEDEX', path='/foo')}
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/foo" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001; SHIPPING=FEDEX'
     b = {'customer': Cookie('WILE_E_COYOTE'),
          'part_number': Cookie('ROCKET_LAUNCHER_0001'),
          'shipping': Cookie('FEDEX')}
     self.assertEqual(CookieDataType.decode(a), b)
示例#2
0
 def test_example1(self):
     # Client requests a document, and receives in the response:
     a = ('CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday,'
          ' 09-Nov-99 23:12:40 GMT')
     b = {
         'customer':
         Cookie('WILE_E_COYOTE',
                path='/',
                expires='Wednesday, 09-Nov-99 23:12:40 GMT')
     }
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE'
     b = {'customer': Cookie('WILE_E_COYOTE')}
     self.assertEqual(CookieDataType.decode(a), b)
     # Client requests a document, and receives in the response:
     a = 'PART_NUMBER=ROCKET_LAUNCHER_0001; path=/'
     b = {'part_number': Cookie('ROCKET_LAUNCHER_0001', path='/')}
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001'
     b = {
         'customer': Cookie('WILE_E_COYOTE'),
         'part_number': Cookie('ROCKET_LAUNCHER_0001')
     }
     self.assertEqual(CookieDataType.decode(a), b)
     # Client receives:
     a = 'SHIPPING=FEDEX; path=/foo'
     b = {'shipping': Cookie('FEDEX', path='/foo')}
     self.assertEqual(SetCookieDataType.decode(a), b)
     # When client requests a URL in path "/foo" on this server, it sends:
     a = 'CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001; SHIPPING=FEDEX'
     b = {
         'customer': Cookie('WILE_E_COYOTE'),
         'part_number': Cookie('ROCKET_LAUNCHER_0001'),
         'shipping': Cookie('FEDEX')
     }
     self.assertEqual(CookieDataType.decode(a), b)
示例#3
0
 def test_set_cookie_decode_encode_decode(self):
     a = 'Customer="WILE_E_COYOTE"; Path="/acme"'
     b = SetCookieDataType.decode(a)
     c = SetCookieDataType.encode(b)
     d = SetCookieDataType.decode(c)
     self.assertEqual(b, d)
示例#4
0
 def test_set_cookie_decode_encode_decode(self):
     a = 'Customer="WILE_E_COYOTE"; Path="/acme"'
     b = SetCookieDataType.decode(a)
     c = SetCookieDataType.encode(b)
     d = SetCookieDataType.decode(c)
     self.assertEqual(b, d)