-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
177 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import sys | ||
import unittest | ||
|
||
sys.path.insert(0, '..') | ||
sys.path.append('..\src') | ||
sys.path.append('src') | ||
|
||
from main_functions import findNovel | ||
from Downloaders import * | ||
from archive_updater import check_env | ||
|
||
class TestMainFunctions(unittest.TestCase): | ||
|
||
def test_find_novel_folder(self): | ||
self.assertTrue(len(findNovel("")) == len(os.listdir('novel_list'))) | ||
|
||
if __name__ == '__main__': | ||
os.mkdir('novel_list') | ||
unittest.main() | ||
# runner = unittest.TextTestRunner() | ||
# runner.run(suite()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import sys | ||
import unittest | ||
|
||
sys.path.insert(0, '..') | ||
sys.path.append('..\src') | ||
sys.path.append('src') | ||
|
||
from main_functions import findNovel | ||
from Downloaders import * | ||
from archive_updater import check_env | ||
|
||
|
||
class Test_factory(unittest.TestCase): | ||
|
||
def setUp(self): | ||
global factory | ||
factory= NovelFactory() | ||
factory.registerObject(SyosetuNovel) | ||
factory.registerObject(N18SyosetuNovel) | ||
factory.registerObject(KakuyomuNovel) | ||
|
||
def test_builder_n18(self): | ||
x= factory.getNovel('n18n2935bp', 'memory rewrite ') | ||
self.assertTrue(x.__class__ == N18SyosetuNovel ) | ||
|
||
def test_builder_syosetu(self): | ||
novel=factory.getNovel('n5080fi') | ||
self.assertTrue(novel.__class__ == SyosetuNovel) | ||
|
||
def test_builder_kakuyomu(self): | ||
novel=factory.getNovel('16816452220453312822') | ||
self.assertTrue(novel.__class__ == KakuyomuNovel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import unittest | ||
from Downloaders import * | ||
|
||
class Test_n18(unittest.TestCase): | ||
|
||
def setUp(self): | ||
global novel | ||
novel=N18SyosetuNovel('n18n6426w',"test", False) | ||
|
||
def test_parse_TOC(self): | ||
html = novel.fetchTOCPage() | ||
self.assertTrue(html != '',"failed to fetch the html page") | ||
toc = novel.parseTocResume(html) | ||
self.assertTrue(toc != '',"failed to parse the TOC resume") | ||
|
||
def test_parse_chapter_list(self): | ||
html = novel.fetchTOCPage() | ||
chapter_list = novel.parseOnlineChapterList(html) | ||
self.assertTrue(len(chapter_list) != 0) | ||
for chap_num in chapter_list: | ||
with self.subTest(i=chap_num): | ||
self.assertIsNotNone(int(chap_num)) | ||
self.assertTrue(int(chap_num) > 0 ) | ||
|
||
def test_parse_chapter_content(self): | ||
chapter = novel.processChapter(1) | ||
self.assertTrue(chapter.content !="") | ||
self.assertTrue(chapter.title != "") | ||
|
||
if __name__ == '__main__': | ||
os.mkdir('novel_list') | ||
unittest.main() | ||
# runner = unittest.TextTestRunner() | ||
# runner.run(suite()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
from Downloaders import * | ||
|
||
class Tests_syosetu(unittest.TestCase): | ||
|
||
|
||
def setUp(self): | ||
global novel | ||
novel= SyosetuNovel('n7671do', "test", False) | ||
|
||
def test_parse_TOC(self): | ||
html = novel.fetchTOCPage() | ||
self.assertTrue(html != '',"failed to fetch the html page") | ||
toc_resume = novel.parseTocResume(html) | ||
self.assertTrue(toc_resume != '',"failed to parse the TOC resume") | ||
print("resume = ",toc_resume) | ||
|
||
def test_parse_chapter_list(self): | ||
html = novel.fetchTOCPage() | ||
chapter_list = novel.parseOnlineChapterList(html) | ||
self.assertTrue(len(chapter_list) != 0) | ||
for chap_num in chapter_list: | ||
with self.subTest(i=chap_num): | ||
self.assertIsNotNone(int(chap_num)) | ||
self.assertTrue(int(chap_num) > 0 ) | ||
|
||
# def test_parse_chapter_content(self): | ||
# chapter = novel.parse([1]) | ||
# self.assertTrue(chapter.content !="") | ||
# self.assertTrue(chapter.title != "") |