Exemplo n.º 1
0
    def test_from_cookie_list(self):
        cookie = create_cookie('foo', 'bar')
        mgr = CookieManager.from_cookie_list([cookie])
        test_cookie = [x for x in mgr.cookiejar if x.name == 'foo'][0]
        self.assertEqual(cookie.name, test_cookie.name)

        mgr = CookieManager.from_cookie_list([])
        self.assertEqual(0, len(list(mgr.cookiejar)))
Exemplo n.º 2
0
    def test_from_cookie_list(self):
        cookie = create_cookie("foo", "bar", self.server.address)
        mgr = CookieManager.from_cookie_list([cookie])
        test_cookie = [x for x in mgr.cookiejar if x.name == "foo"][0]
        self.assertEqual(cookie.name, test_cookie.name)

        mgr = CookieManager.from_cookie_list([])
        self.assertEqual(0, len(list(mgr.cookiejar)))
Exemplo n.º 3
0
    def test_from_cookie_list(self):
        cookie = create_cookie('foo', 'bar', self.server.address)
        mgr = CookieManager.from_cookie_list([cookie])
        test_cookie = [x for x in mgr.cookiejar if x.name == 'foo'][0]
        self.assertEqual(cookie.name, test_cookie.name)

        mgr = CookieManager.from_cookie_list([])
        self.assertEqual(0, len(list(mgr.cookiejar)))
Exemplo n.º 4
0
 def test_pickle_serialization(self):
     cookie = create_cookie('foo', 'bar')
     mgr = CookieManager.from_cookie_list([cookie])
     dump = pickle.dumps(mgr)
     mgr2 = pickle.loads(dump)
     self.assertEqual(list(mgr.cookiejar)[0].value,
                      list(mgr2.cookiejar)[0].value)
Exemplo n.º 5
0
 def test_pickle_serialization(self):
     cookie = create_cookie('foo', 'bar', self.server.address)
     mgr = CookieManager.from_cookie_list([cookie])
     dump = pickle.dumps(mgr)
     mgr2 = pickle.loads(dump)
     self.assertEqual(list(mgr.cookiejar)[0].value,
                      list(mgr2.cookiejar)[0].value)
Exemplo n.º 6
0
    def load_config(self, config):
        """
        Configure grab instance with external config object.
        """

        self.config = copy_config(config, self.mutable_config_keys)
        if 'cookiejar_cookies' in config['state']:
            self.cookies = CookieManager.from_cookie_list(config['state']['cookiejar_cookies'])
Exemplo n.º 7
0
    def load_config(self, config):
        """
        Configure grab instance with external config object.
        """

        self.config = copy_config(config, self.mutable_config_keys)
        if 'cookiejar_cookies' in config['state']:
            self.cookies = CookieManager.from_cookie_list(
                config['state']['cookiejar_cookies'])
Exemplo n.º 8
0
 def test_get_item(self):
     cookie = create_cookie("foo", "bar", self.server.address)
     mgr = CookieManager.from_cookie_list([cookie])
     self.assertEqual("bar", mgr["foo"])
     self.assertRaises(KeyError, lambda: mgr["zzz"])
Exemplo n.º 9
0
 def test_get_item(self):
     cookie = create_cookie('foo', 'bar', self.server.address)
     mgr = CookieManager.from_cookie_list([cookie])
     self.assertEqual('bar', mgr['foo'])
     self.assertRaises(KeyError, lambda: mgr['zzz'])
Exemplo n.º 10
0
 def test_get_item(self):
     cookie = create_cookie('foo', 'bar')
     mgr = CookieManager.from_cookie_list([cookie])
     self.assertEqual('bar', mgr['foo'])
     self.assertRaises(KeyError, lambda: mgr['zzz'])