| 1 |
import textwrap |
| 2 |
|
| 3 |
from beets.library import Item |
| 4 |
from beets.util.lyrics import Lyrics |
| 5 |
|
| 6 |
|
| 7 |
class TestLyrics: |
| 8 |
def test_instrumental_lyrics(self): |
| 9 |
lyrics = Lyrics( |
| 10 |
"[Instrumental]", "lrclib", url="https://lrclib.net/api/1" |
| 11 |
) |
| 12 |
|
| 13 |
assert lyrics.full_text == "" |
| 14 |
assert lyrics.instrumental |
| 15 |
assert lyrics.backend == "lrclib" |
| 16 |
assert lyrics.url == "https://lrclib.net/api/1" |
| 17 |
assert lyrics.language is None |
| 18 |
assert lyrics.translation_language is None |
| 19 |
|
| 20 |
def test_from_item_without_lyrics(self): |
| 21 |
item = Item(lyrics=None) |
| 22 |
|
| 23 |
lyrics = Lyrics.from_item(item) |
| 24 |
|
| 25 |
assert lyrics.text == "" |
| 26 |
assert not lyrics.synced |
| 27 |
assert lyrics.full_text == "" |
| 28 |
assert lyrics.sylt == [] |
| 29 |
assert lyrics.text_lines == [] |
| 30 |
|
| 31 |
def test_from_legacy_text(self, is_importable): |
| 32 |
text = textwrap.dedent(""" |
| 33 |
[00:00.00] Some synced lyrics / Quelques paroles synchronisées |
| 34 |
[00:00.50] |
| 35 |
[00:01.00] Some more synced lyrics / Quelques paroles plus synchronisées |
| 36 |
|
| 37 |
Source: https://lrclib.net/api/1/""") |
| 38 |
|
| 39 |
lyrics = Lyrics.from_legacy_text(text) |
| 40 |
|
| 41 |
assert lyrics.full_text == textwrap.dedent( |
| 42 |
""" |
| 43 |
[00:00.00] Some synced lyrics / Quelques paroles synchronisées |
| 44 |
[00:00.50] |
| 45 |
[00:01.00] Some more synced lyrics / Quelques paroles plus synchronisées""" |
| 46 |
) |
| 47 |
assert lyrics.backend == "lrclib" |
| 48 |
assert lyrics.url == "https://lrclib.net/api/1/" |
| 49 |
langdetect_available = is_importable("langdetect") |
| 50 |
assert lyrics.language == ("EN" if langdetect_available else None) |
| 51 |
assert lyrics.translation_language == ( |
| 52 |
"FR" if langdetect_available else None |
| 53 |
) |
| 54 |
assert not lyrics.instrumental |