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)
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")
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)
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)
def url(self): return URL(self._url, self._path)