# Path: lyric_engine/modules/evesta.py
# class Evesta(LyricBase):
#     def parse_page(self):
#         url = self.url
# 
#         html = self.get_html(url)
#         if not html:
#             logging.info('Failed to get html of url [%s]', url)
#             return False
# 
#         if not self.parse_lyric(html):
#             logging.info('Failed to get lyric of url [%s]', url)
#             return False
# 
#         if not self.parse_song_info(html):
#             logging.info('Failed to get song info of url [%s]', url)
# 
#         return True
# 
#     def get_html(self, url):
#         html = common.get_url_content(url)
#         if not html:
#             return False
# 
#         return html
# 
#     def parse_lyric(self, html):
#         html = html.replace("\r\n", "")
#         prefix = '<div id="lyricbody">'
#         suffix = "</div>"
#         lyric = common.find_string_by_prefix_suffix(
#             html, prefix, suffix, False)
#         if not lyric:
#             logging.info("Failed to parse lyric from html [%s]", html)
#             return False
# 
#         lyric = lyric.replace("<br>", "\n")
#         lyric = lyric.strip()
#         lyric = common.unicode2string(lyric)
#         lyric = common.half2full(lyric)
# 
#         self.lyric = lyric
# 
#         return True
# 
#     def parse_song_info(self, html):
#         prefix = '<div id="lyrictitle">'
#         suffix = "</div>"
#         block = common.find_string_by_prefix_suffix(
#             html, prefix, suffix, False)
# 
#         patterns = {
#             "title": r"<h1>(.*?) 歌詞</h1>",
#             "artist": r">歌：(.*?)</p>",
#             "lyricist": r">作詞：(.*?)</p>",
#             "composer": r">作曲：(.*?)</p>"
#         }
# 
#         self.set_attr(patterns, block)
# 
#         return True


import unittest
from lyric_engine.modules.evesta import Evesta as Lyric

class EvestaTest(unittest.TestCase):
    def test_url_01(self):
        url = 'http://www.evesta.jp/lyric/artists/a10019/lyrics/l65161.html'
        obj = Lyric(url)
        obj.parse()

        self.assertEqual(obj.title, 'Gift')
        self.assertEqual(obj.artist, '坂本真綾')
        self.assertEqual(obj.lyricist, '岩里 祐穂')
        self.assertEqual(obj.composer, '菅野よう子')
        self.assertEqual(len(obj.lyric), 454)

    def test_url_02(self):
        url = 'http://www.evesta.jp/lyric/artists/a10019/lyrics/l65156.html'

# Path: lyric_engine/modules/evesta.py
# class Evesta(LyricBase):
#     def parse_page(self):
#         url = self.url
# 
#         html = self.get_html(url)
#         if not html:
#             logging.info('Failed to get html of url [%s]', url)
#             return False
# 
#         if not self.parse_lyric(html):
#             logging.info('Failed to get lyric of url [%s]', url)
#             return False
# 
#         if not self.parse_song_info(html):
#             logging.info('Failed to get song info of url [%s]', url)
# 
#         return True
# 
#     def get_html(self, url):
#         html = common.get_url_content(url)
#         if not html:
#             return False
# 
#         return html
# 
#     def parse_lyric(self, html):
#         html = html.replace("\r\n", "")
#         prefix = '<div id="lyricbody">'
#         suffix = "</div>"
#         lyric = common.find_string_by_prefix_suffix(
#             html, prefix, suffix, False)
#         if not lyric:
#             logging.info("Failed to parse lyric from html [%s]", html)
#             return False
# 
#         lyric = lyric.replace("<br>", "\n")
#         lyric = lyric.strip()
#         lyric = common.unicode2string(lyric)
#         lyric = common.half2full(lyric)
# 
#         self.lyric = lyric
# 
#         return True
# 
#     def parse_song_info(self, html):
#         prefix = '<div id="lyrictitle">'
#         suffix = "</div>"
#         block = common.find_string_by_prefix_suffix(
#             html, prefix, suffix, False)
# 
#         patterns = {
#             "title": r"<h1>(.*?) 歌詞</h1>",
#             "artist": r">歌：(.*?)</p>",
#             "lyricist": r">作詞：(.*?)</p>",
#             "composer": r">作曲：(.*?)</p>"
#         }
# 
#         self.set_attr(patterns, block)
# 
#         return True


# Path: lyric_engine/tests/test_evesta.py
import unittest
from lyric_engine.modules.evesta import Evesta as Lyric


class EvestaTest(unittest.TestCase):
    def test_url_01(self):
        url = 'http://www.evesta.jp/lyric/artists/a10019/lyrics/l65161.html'
        obj = Lyric(url)
        obj.parse()

        self.assertEqual(obj.title, 'Gift')
        self.assertEqual(obj.artist, '坂本真綾')
        self.assertEqual(obj.lyricist, '岩里 祐穂')
        self.assertEqual(obj.composer, '菅野よう子')
        self.assertEqual(len(obj.lyric), 454)

    def test_url_02(self):
        url = 'http://www.evesta.jp/lyric/artists/a10019/lyrics/l65156.html'

        obj = Lyric(url)