43 lines
902 B
Python
43 lines
902 B
Python
|
from unittest import TestCase
|
||
|
import urllib3
|
||
|
|
||
|
import genius
|
||
|
|
||
|
|
||
|
TITLE = 'A Line In The Sand'
|
||
|
ARTIST = 'Linkin Park'
|
||
|
URL = 'https://genius.com/Linkin-park-a-line-in-the-sand-lyrics'
|
||
|
|
||
|
LYR1 = '''[Intro: Mike Shinoda]
|
||
|
Today, we stood on the wall'''
|
||
|
|
||
|
LYR2 = '''little did we know
|
||
|
|
||
|
[Instrumental Break]
|
||
|
|
||
|
[Verse 1:'''
|
||
|
|
||
|
LYR3 = '''you are gonna get yours
|
||
|
|
||
|
[Chorus: Chester Bennington]
|
||
|
Another day'''
|
||
|
|
||
|
|
||
|
class TestGenius(TestCase):
|
||
|
|
||
|
def setUp(self) -> None:
|
||
|
self.http = urllib3.PoolManager()
|
||
|
|
||
|
def test_search_success(self) -> None:
|
||
|
url = genius.search(self.http, TITLE, ARTIST)
|
||
|
self.assertEqual(url, URL)
|
||
|
|
||
|
def test_lyrics_parsing(self) -> None:
|
||
|
lyrics = genius.parse(self.http, URL)
|
||
|
self.assertTrue(lyrics.startswith(LYR1))
|
||
|
self.assertTrue(LYR2 in lyrics)
|
||
|
self.assertTrue(LYR3 in lyrics)
|
||
|
|
||
|
def tearDown(self) -> None:
|
||
|
self.http.clear()
|