示例#1
0
文件: test_url.py 项目: tor4z/crabs
 def test_query_str(self):
     url = self.url
     url.set_query(self._query)
     self.assertEqual(url.query_str, self._query_string)
     path = "/path?a=1&b=2"
     url = URL(self._url, path)
     self.assertEqual(url.query_str, "a=1&b=2")
示例#2
0
 def test_size(self):
     pool = URLPool()
     count = random.randint(10, 20)
     for i in range(count):
         url = URL(self._url)
         pool.put_url(url)
     self.assertEqual(pool.size, count)
示例#3
0
    def travel_mod(self):
        pool = URLPool()
        n = 10

        for i in range(n):
            url = URL(self._url, depth=1)
            pool.put_url(url)

        pool.set_treval_mod(Treval.BFS)
        url = pool.get_url()
        self.assertEqual(url.depth, 0)
        pool.set_treval_mod(Treval.DFS)
        url = pool.get_url()
        self.assertEqual(url.depth, n - 1)
示例#4
0
文件: test_url.py 项目: tor4z/crabs
 def test_is_full_url(self):
     url1 = "http://www.aaa.com/path?sdsd=ss"
     url2 = "/path?uu=11"
     self.assertTrue(URL.is_full_url(url1))
     self.assertFalse(URL.is_full_url(url2))
示例#5
0
文件: test_url.py 项目: tor4z/crabs
 def test_dict_to_qs(self):
     self.assertEqual(URL.dict_to_qs(self._query), self._query_string)
示例#6
0
文件: test_url.py 项目: tor4z/crabs
 def test_urljoin(self):
     target = "http://www.aaa.com/bbb"
     origin = "http://www.aaa.com/aaa"
     self.assertEqual(URL.urljoin(origin, target), target)
     self.assertEqual(URL.urljoin(origin, "/bbb"), target)
示例#7
0
文件: test_url.py 项目: tor4z/crabs
 def test_query(self):
     path = "/path?a=1&b=2"
     d = {"a": "1", "b": "2"}
     url = URL(self._url, path)
     self.assertEqual(url.query, d)
示例#8
0
文件: test_url.py 项目: tor4z/crabs
 def url(self):
     return URL(self._url, self._path)