Add additional methods to fetch lyrics

The following inputs can now be used to fetch lyrics:
* artist and track names
* search query
* direct url
This commit is contained in:
Ritiek Malhotra
2020-04-08 21:43:58 +05:30
parent 51da0b7a29
commit 47247f7250
7 changed files with 210 additions and 76 deletions

View File

@@ -11,15 +11,16 @@ class TestLyricWikia:
def test_subclass(self):
assert issubclass(LyricWikia, LyricBase)
def test_get_lyrics(self, monkeypatch):
def test_from_artist_and_track(self, monkeypatch):
# `LyricWikia` class uses the 3rd party method `lyricwikia.get_lyrics`
# internally and there is no need to test a 3rd party library as they
# have their own implementation of tests.
monkeypatch.setattr(
"lyricwikia.get_lyrics", lambda a, b, c, d: "awesome lyrics!"
)
track = LyricWikia("Lyricwikia", "Lyricwikia")
assert track.get_lyrics() == "awesome lyrics!"
artist, track = "selena gomez", "wolves"
lyrics = LyricWikia().from_artist_and_track(artist, track)
assert lyrics == "awesome lyrics!"
def test_lyrics_not_found_error(self, monkeypatch):
def lyricwikia_lyrics_not_found(msg):
@@ -30,6 +31,6 @@ class TestLyricWikia:
"lyricwikia.get_lyrics",
lambda a, b, c, d: lyricwikia_lyrics_not_found("Nope, no lyrics."),
)
track = LyricWikia("Lyricwikia", "Lyricwikia")
artist, track = "nonexistent_artist", "nonexistent_track"
with pytest.raises(exceptions.LyricsNotFoundError):
track.get_lyrics()
LyricWikia().from_artist_and_track(artist, track)