Skip to content
This repository has been archived by the owner on Oct 16, 2022. It is now read-only.

Commit

Permalink
tmp: kissmanga tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanb committed Jun 9, 2015
1 parent 90e588c commit 42947be
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
20 changes: 20 additions & 0 deletions fundoshi/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def _test_series(case, site, url, expected):
"""
Helper to use in site-specific test cases. See test_kissmanga.py for usage.
"""
resp = site.get_manga_seed_page(url)
if resp.status_code != 200:
raise Exception('Failed to download series html')
html = resp.text
series = site.series_info(html)

chapters = expected.pop('chapters', None)

for key, val in expected.items():
case.assertEqual(getattr(series, key), val)

if chapters is None:
return
case.assertEqual(series.chapters[-1], chapters['first'])
if 'last' in chapters:
case.assertEqual(series.chapters[0], chapters['last'])
35 changes: 32 additions & 3 deletions fundoshi/tests/test_kissmanga.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
import unittest
from fundoshi.sites.kissmanga import Kissmanga
from . import _test_series
site = Kissmanga()


class TestSeriesInfo(unittest.TestCase):
def test_series_info(self):
pass
class TestKissmangaSeries(unittest.TestCase):

def test_completed_series(self):
url = 'http://kissmanga.com/Manga/Beelzebub'
expected = {
'name': 'Beelzebub',
'tags': ['action', 'comedy', 'fantasy', 'manga', 'school life',
'shounen', 'supernatural'],
'thumb_url': 'http://kissmanga.com/Uploads/Etc/8-17-2011/75210229ef3c651a3.jpg',
'status': 'completed',
'description': [
'The story follows the "strongest juvenile delinquent" as he watches over '
"the devil king's son (and future devil king) with the fate of the world "
'hanging in the balance.'
],
'authors': ['Tamura Ryuuhei'],
'chapters': {
'last': {
'url': 'http://kissmanga.com/Manga/Beelzebub/Ch-240--Last-Babu'
'--Good-Babu--Ishiyama-High--End-?id=188430',
'name': 'Beelzebub 240: Last Babu, Good Babu, Ishiyama High [End]'
},
'first': {
'url': 'http://kissmanga.com/Manga/Beelzebub/Vol-1-Ch-01-Read-Online?id=407',
'name': 'Beelzebub 001 Read Online',
},
},
}
_test_series(self, site, url, expected)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
exclude = fundoshi/tests/test_*

0 comments on commit 42947be

Please sign in to comment.