# Path: cum/exceptions.py
# class CumException(Exception):
# class LoginError(CumException):
# class ScrapingError(CumException):
# class ConfigError(CumException):
#     def __init__(self, message=''):
#     def __str__(self):
#     def __init__(self, config, cursor, message=''):


from cum import exceptions
from cumtest import CumTest
        from cum.scrapers import dokireader
import os
import zipfile

class TestDokiReader(CumTest):
    def setUp(self):
        super().setUp()
        global dokireader

    def test_chapter_technobreak_company_1(self):
        URL = ('https://kobato.hologfx.com/reader/read/'
               'technobreak_company/en/0/1/page/1')
        URL_SHORT = ('https://kobato.hologfx.com/reader/read/'
                     'technobreak_company/en/0/1/')
        ALIAS = 'technobreak-company'
        NAME = 'Technobreak Company'
        chapter = dokireader.DokiReaderChapter.from_url(URL)
        self.assertEqual(chapter.alias, ALIAS)
        self.assertTrue(chapter.available())
        self.assertEqual(chapter.chapter, '1')
        self.assertIs(chapter.directory, None)
        self.assertEqual(chapter.groups, ['Doki Fansubs'])
        self.assertEqual(chapter.name, NAME)
        self.assertEqual(chapter.url, URL_SHORT)
        path = os.path.join(self.directory.name, NAME,
                            'Technobreak Company - c001 [Doki Fansubs].zip')
        self.assertEqual(chapter.filename, path)
        chapter.download()
        self.assertTrue(os.path.isfile(path))
        with zipfile.ZipFile(path) as chapter_zip:
            files = chapter_zip.infolist()
            self.assertEqual(len(files), 18)


# Path: cum/exceptions.py
# class CumException(Exception):
# class LoginError(CumException):
# class ScrapingError(CumException):
# class ConfigError(CumException):
#     def __init__(self, message=''):
#     def __str__(self):
#     def __init__(self, config, cursor, message=''):


# Path: tests/test_scraper_dokireader.py
from cum import exceptions
from cumtest import CumTest
        from cum.scrapers import dokireader
import os
import zipfile


class TestDokiReader(CumTest):
    def setUp(self):
        super().setUp()
        global dokireader

    def test_chapter_technobreak_company_1(self):
        URL = ('https://kobato.hologfx.com/reader/read/'
               'technobreak_company/en/0/1/page/1')
        URL_SHORT = ('https://kobato.hologfx.com/reader/read/'
                     'technobreak_company/en/0/1/')
        ALIAS = 'technobreak-company'
        NAME = 'Technobreak Company'
        chapter = dokireader.DokiReaderChapter.from_url(URL)
        self.assertEqual(chapter.alias, ALIAS)
        self.assertTrue(chapter.available())
        self.assertEqual(chapter.chapter, '1')
        self.assertIs(chapter.directory, None)
        self.assertEqual(chapter.groups, ['Doki Fansubs'])
        self.assertEqual(chapter.name, NAME)
        self.assertEqual(chapter.url, URL_SHORT)
        path = os.path.join(self.directory.name, NAME,
                            'Technobreak Company - c001 [Doki Fansubs].zip')
        self.assertEqual(chapter.filename, path)
        chapter.download()
        self.assertTrue(os.path.isfile(path))
        with zipfile.ZipFile(path) as chapter_zip:
            files = chapter_zip.infolist()
            self.assertEqual(len(files), 18)


    def test_series_invalid(self):