beets
beets copied to clipboard
Refactor lyrics tests, do not search for empty metadata
Description
Fixes #2635 Fixes #5133
I realised that #5406 has gotten too big, thus I'm splitting it into several smaller PRs.
This PR refactors lyrics plugin tests and fixes an empty metadata issue in the lyrics logic.
CI
- Added
--extras=lyricsto the Poetry install command to include the lyrics plugin dependencies. - In the main task which measures coverage, set
LYRICS_UPDATEDenvironment variable based on changes detected in the lyrics files.
Test setup
- Introduced
ConfigMixinto centralize configuration setup for tests, reducing redundancy. This can be used by tests based onpytest.
Lyrics logic
- Trimmed whitespace from
item.title,item.artist, anditem.artist_sortinsearch_pairsfunction. - Added checks to avoid searching for lyrics if either the artist or title is missing.
- Improved
_scrape_strip_cruftfunction to remove Google Ads tags and unnecessary HTML tags.
Lyrics tests overhaul
- Migrated lyrics tests to use
pytestfor better isolation and configuration management. - Deleted redundant lyrics text files and some unused utils.
- Marked tests that should only run when lyrics source code is updated (
LYRICS_UPDATEDis set from the CI) using theon_lyrics_updatemarker.
Documentation and Dependencies
- Added
requests-mockversion1.12.1topyproject.tomlandpoetry.lockfor mocking HTTP requests in tests. - Updated
setup.cfgto include a new markeron_lyrics_update.
@bal-e added a pair of additional commits as I noticed that LRCLib integrated tests have been testing no-op logic and failed once I configured it correctly.
I also added lyrics texts that we're expecting to receive from each of the sources we're testing. These will be helpful to have when changes are made in the backends' scraping logic.