beets icon indicating copy to clipboard operation
beets copied to clipboard

Refactor lyrics tests, do not search for empty metadata

Open snejus opened this issue 1 year ago • 1 comments

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=lyrics to the Poetry install command to include the lyrics plugin dependencies.
  • In the main task which measures coverage, set LYRICS_UPDATED environment variable based on changes detected in the lyrics files.

Test setup

  • Introduced ConfigMixin to centralize configuration setup for tests, reducing redundancy. This can be used by tests based on pytest.

Lyrics logic

  • Trimmed whitespace from item.title, item.artist, and item.artist_sort in search_pairs function.
  • Added checks to avoid searching for lyrics if either the artist or title is missing.
  • Improved _scrape_strip_cruft function to remove Google Ads tags and unnecessary HTML tags.

Lyrics tests overhaul

  • Migrated lyrics tests to use pytest for 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_UPDATED is set from the CI) using the on_lyrics_update marker.

Documentation and Dependencies

  • Added requests-mock version 1.12.1 to pyproject.toml and poetry.lock for mocking HTTP requests in tests.
  • Updated setup.cfg to include a new marker on_lyrics_update.

snejus avatar Oct 03 '24 13:10 snejus

@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.

snejus avatar Oct 18 '24 21:10 snejus