def test_crawl_passes_crawljob_to_work_service(self): crawler = Crawler() crawler.crawl("bar") self.assertEqual( Inject.features['work_service'].request_work.call_count(), 1) job = Inject.features['work_service'].request_work.calls[0][0][0] self.assertTrue(callable(job))
def test_can_create(self): self.assertTrue(Crawler()) self.assertTrue(Crawler("https://someuri"))
def test_crawl_calls_on_start(self): crawler = Crawler() callback = CallableMock() crawler.on_start(callback) crawler.crawl("foo") self.assertEqual(callback.call_count(), 1)
def test_initialize_status_inits_status_correctly(self): crawler = Crawler() urls = ["http://a", "http://b", "http://c"] crawler.initialize_status(urls) self.__assert_status(crawler.status, set(), set(urls), [])
def test_initialize_status_https(self): crawler = Crawler() urls = ["https://winnie"] crawler.initialize_status(urls) self.assertEqual(crawler.protocol, "https://")
def test_init(self): urls = ["https://fubar.com"] crawler = Crawler(urls[0]) self.__assert_status(crawler.status, set(), set(urls), [])