Commit graph

2732 commits

Author SHA1 Message Date
J0J0 Todos
1c14574e85 Add lastgenre testcase with unicode \0 separator 2025-01-21 17:04:02 +01:00
J0J0 Todos
a434ecfe7b Refactor _get_genre test to parametrized pytest 2025-01-21 17:04:02 +01:00
J0J0 Todos
70d641c556 Experiment with test_lastgenre 2025-01-21 17:04:02 +01:00
Šarūnas Nejus
bb5f3e0593
lyrics: sort lrclib lyrics by synced field and query search first
I found that the `/get` endpoint often returns incorrect or unsynced
lyrics, while results returned by the `/search` more accurate options.

Thus I reversed the change in the previous commit to prioritize
searching first.
2025-01-20 13:14:37 +00:00
Šarūnas Nejus
618c3a21a6
Try to GET LRCLib lyrics before searching 2025-01-19 18:39:54 +00:00
Šarūnas Nejus
2fb72c65a5
lyrics/LRCLib: handle instrumental lyrics 2025-01-19 15:19:44 +00:00
Šarūnas Nejus
a398fbe62d
LRCLib: Improve exception handling 2025-01-19 15:19:44 +00:00
Šarūnas Nejus
8d4a569291
Fix fetching lyrics from lrclib
Adjust the base URL to perform a '/search' instead of attempting to
'/get' specific lyrics where we're unlikely to find lyrics for the
specific combination of album, artist, track names and the duration (see
https://lrclib.net/docs).

Since we receive an array of matching lyrics candidates, rank them by
their duration similarity to the item's duration, and whether they
contain synced lyrics.
2025-01-19 15:19:41 +00:00
Šarūnas Nejus
e5c006d99d
Test lyrics texts explicitly
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.
2025-01-19 01:54:53 +00:00
Šarūnas Nejus
c250bfa724
Google: test the entire fetch method 2025-01-19 01:48:04 +00:00
Šarūnas Nejus
334bbde826
Make album, duration required for LyricsPlugin.fetch
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.
2025-01-19 01:48:04 +00:00
Šarūnas Nejus
0a12d07a94
Do not attempt to fetch lyrics with empty data
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.
2025-01-19 01:48:04 +00:00
Šarūnas Nejus
767a83fbe6
Refactor utils test cases to use pytest.mark.parametrize 2025-01-19 01:48:04 +00:00
Šarūnas Nejus
f674d65a65
Refactor search_pairs tests to use pytest parametrize
- 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.
2025-01-19 01:48:04 +00:00
Šarūnas Nejus
14fd151f80
Refactor test_slug to pytest 2025-01-19 01:48:04 +00:00
Šarūnas Nejus
67e0af526c
Remove outdated GeniusLyrics test
The test for GeniusLyrics was heavily patched and no longer provided
useful coverage. It has been removed to clean up the test suite.
2025-01-19 01:48:04 +00:00
Šarūnas Nejus
35dcfe508a
Configure integrated lyrics tests to only run on lyrics code changes 2025-01-19 01:48:03 +00:00
Šarūnas Nejus
fc49902f3a
Refactor lyrics backend tests to use pytest fixtures
- 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.
2025-01-19 01:33:15 +00:00
Šarūnas Nejus
b9bc2cbc04
lyrics: isolate test configuration
(#5102) Refactor lyrics tests which depended on local developer beets
configuration.
2025-01-19 01:33:14 +00:00
Šarūnas Nejus
29a3dd5084
Remove redundant lyrics test files 2025-01-19 01:32:17 +00:00
Šarūnas Nejus
e99d457c9d
Rewrite lyrics integration tests 2025-01-19 01:32:17 +00:00
Šarūnas Nejus
d22c497dc0
Use table-qualified names in any field query
In order to include the table name for fields in this query, use the
`field_query` method.

Since `AnyFieldQuery` is just an `OrQuery` under the hood, remove it and
construct `OrQuery` explicitly instead.
2025-01-19 01:09:11 +00:00
Šarūnas Nejus
69faa58bab
Unify query construction logic
Unify query creation logic from
- queryparse.py:construct_query_part,
- Model.field_query,
- DefaultTemplateFunctions._tmpl_unique

to a single implementation under `LibModel.field_query` class method.
This method should be used for query resolution for model fields.
2025-01-19 01:09:11 +00:00
Šarūnas Nejus
3bb8af819e
Ignore this test 2025-01-13 22:48:14 +00:00
Šarūnas Nejus
0a53a930aa
Fix release formatting for new versions of pandoc
Ubuntu version in GitHub Actions has recently been upgraded to 24.04:
  https://github.com/actions/runner-images/issues/10636)

This meant that pandoc was upgraded and it changed the way markdown is
formatted by default.
2025-01-13 05:21:01 +00:00
Šarūnas Nejus
801bac5f9e
Release: Fix changelog formatting (#5529)
# Improve release notes formatting / changelog conversion from rst to md

During our last release, we discovered issues with changelog formatting.
This PR improves and fixes several aspects:

## Changes
- Rewrite the changelog conversion logic to be more robust and
maintainable
- Fix indentation issues with nested bullet points
- Improve handling of long section headers
- Order bullet points alphabetically within sections for better
readability
- Use Sphinx `objects.inv` to resolve references and include links to
the documentation in _Markdown_
- Add tests to prevent formatting regressions
- Add pandoc as a dependency for Ubuntu CI builds
- Ensure documentation is built before generating changelog
2025-01-04 01:46:01 +00:00
Šarūnas Nejus
c01d0591f5
Fix track matching regression (#5571)
## Problem
A regression was introduced when adjusting the track matching logic to
use `lapjv` instead of `munkres`. The `lapjv` algorithm returns `-1` for
unmatched items, which wasn't being handled correctly in the matching
logic. This caused incorrect track assignments when importing new music.

## Solution
- Modified the mapping creation to filter out unmatched items (where
index is `-1`)
- Updated test case to properly catch this scenario
2025-01-04 01:42:35 +00:00
valrus
80a10c7e4e lint 2024-12-31 15:14:32 -08:00
valrus
7f469eea54 format 2024-12-31 15:13:42 -08:00
valrus
342ac283b6 improve names 2024-12-31 15:10:50 -08:00
valrus
21c734bff8 patch rather than overwriting Item 2024-12-31 14:50:44 -08:00
Šarūnas Nejus
ef902ea14f
item assignment: set track distance configuration in tests explicitly
These tests depend on certain `track_length_grace` and
`track_length_max` configuration which was set by other tests in this
module.

I discovered this issue when I tried to run
`test_order_works_when_track_names_are_entirely_wrong` test only
- I found that my local configuration was read and the test failed.
2024-12-31 08:13:13 +00:00
Šarūnas Nejus
084cf6490e
matching: add additional test cases and refactor tests 2024-12-31 08:12:03 +00:00
Šarūnas Nejus
0d6393e712
Fix track matching
I had previously tested the `munkres` -> `lapjv` replacement
extensively, so I was today surprised to find that nothing gets matched
correctly when I tried importing some new tracks.

On the other hand I now remember making a small adjustment in the logic
to make autotagging tests pass which is when I introduced a bug: I did
not realize that `lapjv` returns index '-1' for each unmatched item.

This issue did not get caught by tests because this 'unmatched' item
index '-1' anecdotally ended up pointing to the last (expected) item in
the test making it pass.

This commit adjusts the aforementioned test to catch this issue and
fixes the logic to correctly identify unmatched tracks.
2024-12-31 00:08:10 +00:00
valrus
5882e2cf67 Fix sorting on missing int fields 2024-12-29 08:01:41 -08:00
Šarūnas Nejus
eb557f720d
Resolve all URLs for markdown 2024-12-28 07:26:04 +00:00
Šarūnas Nejus
e579df0a98
Can we link users to plugin docs? 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
779ba791f9
Cap maximum sub-section name length 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
0b905e1b17
Ignore literal code blocks when making headers 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
6d602effc3
Add a test for literal code block 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
806c1702fb
Fix wrapped line starting with the username role 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
89afb8cd89
Test wrapped line starting with the username role 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
c26473e6cb
Fix nested bullet points conversion 2024-12-28 07:24:23 +00:00
Šarūnas Nejus
dd96928f38
Test nested bullet points conversion 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
d98226aa07
Fix ordering bullet point lists 2024-12-28 07:24:22 +00:00
Šarūnas Nejus
7b9625bc86
Test rst to md conversion 2024-12-28 07:24:22 +00:00
Stefano Rivera
bcc79a5b09 Future proof BucketPluginTest.test_year_single_year_last_folder
2025 won't be in the future, forever.

Fixes: https://bugs.debian.org/1091495
2024-12-27 16:28:38 -04:00
Šarūnas Nejus
a091c2eeae
Ensure that list fields are corrected for album metadata too 2024-12-15 00:12:36 +00:00
Šarūnas Nejus
550a9a82b1
Fix mb_artistid, mb_albumartistid, albumtype diff issue 2024-12-14 21:39:47 +00:00
Šarūnas Nejus
5c81f94cf7
Move imports required for typing under the TYPE_CHECKING block 2024-12-10 06:10:04 +00:00