示例#1
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)
示例#2
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")
示例#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_query(self):
     path = "/path?a=1&b=2"
     d = {"a": "1", "b": "2"}
     url = URL(self._url, path)
     self.assertEqual(url.query, d)
示例#5
0
文件: test_url.py 项目: tor4z/crabs
 def url(self):
     return URL(self._url, self._path)