-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor lyrics tests, do not search for empty metadata #5452
Open
snejus
wants to merge
14
commits into
adjust-sphinx-post-update
Choose a base branch
from
lyrics-refactor-tests
base: adjust-sphinx-post-update
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snejus
force-pushed
the
lyrics-refactor-tests
branch
4 times, most recently
from
October 3, 2024 19:11
626bf91
to
273e39b
Compare
bal-e
reviewed
Oct 5, 2024
snejus
force-pushed
the
lyrics-refactor-tests
branch
3 times, most recently
from
October 12, 2024 01:15
200cd19
to
9e67a56
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
2 times, most recently
from
October 12, 2024 01:48
b4d78da
to
038ca48
Compare
bal-e
reviewed
Oct 12, 2024
snejus
force-pushed
the
lyrics-refactor-tests
branch
2 times, most recently
from
October 12, 2024 22:10
2fb6682
to
d02e017
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
2 times, most recently
from
October 18, 2024 21:14
54f06f9
to
19dff1c
Compare
@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
force-pushed
the
lyrics-refactor-tests
branch
from
October 19, 2024 00:48
19dff1c
to
e70f61b
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
October 30, 2024 19:23
e70f61b
to
278279e
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
November 22, 2024 07:27
278279e
to
4970dda
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
December 7, 2024 16:56
4970dda
to
09863b8
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
2 times, most recently
from
January 12, 2025 20:36
a4111b8
to
44b4b46
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
January 12, 2025 22:56
c5123f9
to
a4b45e9
Compare
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
January 12, 2025 23:09
a4b45e9
to
2b80596
Compare
snejus
force-pushed
the
adjust-sphinx-post-update
branch
5 times, most recently
from
January 13, 2025 22:48
d2eaa89
to
3bb8af8
Compare
Two google sources failed to return the expected output. I looked into each case why parsing failed: - lyrics on musica.com contain <aside> Google Ads - each lyrics line on lacoccinelle.net is wrapped within alternating <em> and <strong> tags Thus remove these tags as part of the HTML cleanup logic.
(#5102) Refactor lyrics tests which depended on local developer beets configuration.
- Replaced unittest.mock with pytest fixtures for better test isolation and readability. - Simplified test cases by using parameterized tests. - Added `requests-mock` dependency to `pyproject.toml` and `poetry.lock`. - Removed redundant helper functions and classes.
The test for GeniusLyrics was heavily patched and no longer provided useful coverage. It has been removed to clean up the test suite.
- Consolidated multiple test cases into parameterized tests for better readability and maintainability. - Simplified assertions by comparing lists of actual and expected artists/titles. - Added `unexpected_empty_artist` marker to handle cases which unexpectedly return an empty artist. This seems to be happen when `artist_sort` field is empty.
Modified `search_pairs` function in `lyrics.py` to: * Firstly strip each of `artist`, `artist_sort` and `title` fields * Only generate alternatives if both `artist` and `title` are not empty * Ensure that `artist_sort` is not empty and not equal to artist (ignoring case) before appending it to the artists Extended tests to cover the changes.
Since at least one Backend requires album` and `duration` arguments (`LRCLib`), the caller (`LyricsPlugin.fetch_item_lyrics`) must always provide them. Since they need to provided, we need to enforce this by defining them as positional arguments. Why is this important? I found that integrated `LRCLib` tests have been passing, but they called `LRCLib.fetch` with values for `artist` and `title` fields only, while the actual functionality *always* provides values for `album` and `duration` fields too. When I adjusted the test to provide values for the missing fields, I found that it failed. This makes sense: Lib `album` and `duration` filters are strict on LRCLib, so I was not surprised the lyrics could not be found. Thus I adjusted `LRCLib` backend implementation to only filter by each of these fields when their values are truthy.
Add explicit checks for lyrics texts fetched from the tested sources. - Introduced `LyricsPage` class to represent lyrics pages for integrated tests. - Configured expected lyrics for each of the URLs that are being fetched. - Consolidated integrated tests in a new `TestLyricsSources` class. - Mocked Google Search API to return the lyrics page under test.
snejus
force-pushed
the
lyrics-refactor-tests
branch
from
January 13, 2025 22:55
2b80596
to
02386cc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
--extras=lyrics
to the Poetry install command to include the lyrics plugin dependencies.LYRICS_UPDATED
environment variable based on changes detected in the lyrics files.Test setup
ConfigMixin
to centralize configuration setup for tests, reducing redundancy. This can be used by tests based onpytest
.Lyrics logic
item.title
,item.artist
, anditem.artist_sort
insearch_pairs
function._scrape_strip_cruft
function to remove Google Ads tags and unnecessary HTML tags.Lyrics tests overhaul
pytest
for better isolation and configuration management.LYRICS_UPDATED
is set from the CI) using theon_lyrics_update
marker.Documentation and Dependencies
requests-mock
version1.12.1
topyproject.toml
andpoetry.lock
for mocking HTTP requests in tests.setup.cfg
to include a new markeron_lyrics_update
.