def test_worker_add_links_max_limit(self): worker = None worker = BasicUserParseWorker("https://www.reddit.com/user/Chrikelnel") worker.max_links = 0 len_to_crawl_before = len(worker.to_crawl) worker.add_links("test.com") len_to_crawl_after = len(worker.to_crawl) self.assertEqual(len_to_crawl_after, len_to_crawl_before)
def test_worker_add_links_under_max_limit(self): worker = None worker = BasicUserParseWorker("https://www.reddit.com/user/Chrikelnel") worker.max_links = 7 # max_links = 7 now len_to_crawl_before = len(worker.to_crawl) worker.add_links("test.com") len_to_crawl_after = len(worker.to_crawl) self.assertNotEqual( len_to_crawl_after, len_to_crawl_before) # Check that add_links adds links successfuly
def test_zelan_test_one(self): """ this test is to test if add one to worker correctly """ worker = None worker = BasicUserParseWorker("https://www.reddit.com") worker.crawled = [] worker.max_links = 5 len_to_crawl_before = len(worker.to_crawl) worker.add_links(["https://www.reddit.com/user/Chrikelnel"]) len_to_crawl_after = len(worker.to_crawl) self.assertEqual(len_to_crawl_after, len_to_crawl_before + 1)
def test_worker_add_links(self): worker = BasicUserParseWorker("https://www.reddit.com/user/Chrikelnel") worker.max_links = 10 for i in range(1, 5): worker.add_links(['link' + str(i)]) self.assertEqual(len(worker.to_crawl), 5) links_list = [] for i in range(5, 10): links_list.append('link' + str(i)) worker.add_links(links_list) self.assertEqual(len(worker.to_crawl), 10)