def test_chapter_1(self): dummy_manga_site = MangaSite('test_site') dummy_manga = Manga('test_manga', 'test_manga_url', dummy_manga_site) dummy_chapter1 = Chapter(dummy_manga) self.assertTrue(dummy_chapter1.number_of_pages() == 0) self.assertIsNone(dummy_chapter1.title) dummy_chapter2 = Chapter(dummy_manga, 'test_chapter_title') self.assertTrue(dummy_chapter2.title == 'test_chapter_title') dummy_chapter2.set_downloaded(True) self.assertTrue(dummy_chapter2.downloaded) self.assertTrue(dummy_chapter2.in_memory) dummy_chapter2.clear_state() self.assertFalse(dummy_chapter2.downloaded) self.assertFalse(dummy_chapter2.in_memory) try: dummy_chapter2.get_download_path(os.getcwd()) except Exception as e: self.assertIsInstance(e, AttributeError) self.assertTrue("NoneType" in str(e)) dump = dummy_chapter2.dump() self.assertIsInstance(dump, bytes) self.assertTrue(len(dump) > 0)
def crawl_chapter(self, chapter: Chapter): site = self.cwd_site crawler = self.__get_crawler(site.site_name) if crawler: crawler.download(chapter) chapter.set_downloaded(True)