2024-04-27 21:08:20 +03:00
|
|
|
from unittest import TestCase
|
|
|
|
import urllib3
|
|
|
|
|
|
|
|
import genius
|
2024-04-28 13:07:30 +03:00
|
|
|
import http_pool
|
2024-04-27 21:08:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
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:
|
2024-04-28 13:07:30 +03:00
|
|
|
http_pool.get()
|
2024-04-27 21:08:20 +03:00
|
|
|
|
|
|
|
def test_search_success(self) -> None:
|
2024-04-28 13:07:30 +03:00
|
|
|
url = genius.search(TITLE, ARTIST)
|
2024-04-27 21:08:20 +03:00
|
|
|
self.assertEqual(url, URL)
|
|
|
|
|
|
|
|
def test_lyrics_parsing(self) -> None:
|
2024-04-28 13:07:30 +03:00
|
|
|
lyrics = genius.parse(URL)
|
2024-04-27 21:08:20 +03:00
|
|
|
self.assertTrue(lyrics.startswith(LYR1))
|
|
|
|
self.assertTrue(LYR2 in lyrics)
|
|
|
|
self.assertTrue(LYR3 in lyrics)
|
|
|
|
|
|
|
|
def tearDown(self) -> None:
|
2024-04-28 13:07:30 +03:00
|
|
|
http_pool.get().clear()
|