Commit graph

2690 commits

Author SHA1 Message Date
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
valrus
5882e2cf67 Fix sorting on missing int fields 2024-12-29 08:01:41 -08: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
Šarūnas Nejus
161b0522bb
Update deprecated imports 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
51f9dd229e
Use PEP585 lowercase collections typing annotations 2024-12-10 06:10:03 +00:00
Šarūnas Nejus
7be8f9c97a
Update CI config, minimum ruff version, docs and add changelog note 2024-12-10 06:10:03 +00:00
Edgars Supe
09360259cc lyrics: Fallback to plain lyrics if synced not available 2024-12-07 19:08:37 +02:00
Stefano Rivera
336b5b369e Skip autobpm tests if librosa isn't available
Except under GitHub CI, where we expect all tests to run.
2024-11-30 09:32:08 -04:00
Šarūnas Nejus
65e935bee5
Perform a regex substitution in the substitute plugin (#5357)
This utilises regex substitution in the substitute plugin. The previous
approach only used regex to match the pattern, then replaced it with a
static string. This change allows more complex substitutions, where the
output depends on the input.

### Example use case
Say we want to keep only the first artist of a multi-artist credit, as
in the following list:
```
Neil Young & Crazy Horse -> Neil Young
Michael Hurley, The Holy Modal Rounders, Jeffrey Frederick & The Clamtones -> Michael Hurley
James Yorkston and the Athletes -> James Yorkston
````
This would previously have required three separate rules, one for each
resulting artist. By using a regex substitution, we can get the desired
behaviour in a single rule:
```yaml
substitute:
  ^(.*?)(,| &| and).*: \1
```
(Capture the text until the first `,` ` &` or ` and`, then use that
capture group as the output)

### Notes
I've kept the previous behaviour of only applying the first matching
rule, but I'm not 100% sure it's the ideal approach.
I can imagine both cases where you want to apply several rules in
sequence and cases where you want to stop after the first match.
2024-11-22 05:02:50 +00:00
Šarūnas Nejus
de171f03fc
Test helpers: Remove unneeded data generation abstractions (#5463)
This PR refactors the test codebase by removing redundant functions and
simplifying item and album creation. Key changes include:

- Removed redundant `_item_ident` index tracker from `_common.py`.
- Removed `album` function from `_common.py` replacing it with direct
`library.Album` invocations.
- Removed `generate_album_info` and `generate_track_info` functions,
replacing them directly with `TrackInfo` and `AlbumInfo`.
- Updated `setup.cfg` to exclude test helper files from coverage
reports.
- Adjusted the tests regarding the changes, and simplified
`test_mbsync.py`.
2024-11-13 14:16:15 +00:00
Adam Harder
d6ac687de1 fix #4840 and add to test case 2024-11-06 23:14:47 -05:00
Šarūnas Nejus
69dbfd9868
Fix lints
These seem to have managed to escape the CI checks since the previously
merged PR was based on master commit which did not include the checks.
2024-10-30 12:13:30 +00:00
Joseph Bushell
4b78abd939 create seperate in_no_convert function, update tests 2024-10-26 19:09:56 +01:00
Joseph Bushell
bba11be9f7 update test assertions 2024-10-26 18:17:39 +01:00
Joseph Bushell
a73919b4ba add test for no_convert when using OR query 2024-10-26 18:17:27 +01:00
Joseph Bushell
d1c88bbd25 consider value of no_convert as one query rather than splitting 2024-10-26 18:17:00 +01:00
Nicholas Boyd Isacsson
8e0558b804 Apply substitute rules in sequence 2024-10-16 16:36:36 +02:00
Nicholas Boyd Isacsson
19eb729db3 Refactor tests to make 2024-10-16 16:35:39 +02:00
Šarūnas Nejus
41907a96a6
Remove _common.album and use Album instead 2024-10-16 12:37:22 +01:00
Šarūnas Nejus
d161111342
test helpers: remove redundant _get_item_count
It always returns 1.
2024-10-16 12:33:17 +01:00
Šarūnas Nejus
2681c83c5b
Remove redundant generate_album_info and generate_track_info functions
These functions were used to generate mock data for tests but have been
replaced with direct instantiation of AlbumInfo and TrackInfo objects.
This change simplifies the test code and removes unnecessary helper
functions.
2024-10-16 06:39:30 +01:00
Nicholas Boyd Isacsson
ffdc3f73ab Revert configuration format changes 2024-10-14 22:54:38 +02:00
Nicholas Boyd Isacsson
195644fc46 Refactor according to review comments 2024-10-12 15:34:05 +02:00
Šarūnas Nejus
d3955bac65
Update Tekstowo backend to fetch lyrics directly
- Refactored Tekstowo backend to fetch lyrics directly from song pages.
- Added `encode` method to convert artist and title to their URL format,
  where non-alphanumeric characters are replaced with underscores.
- Removed the now redundant search functionality and associated tests.
- Simplified `extract_lyrics` method to directly parse lyrics without
  any checks.
2024-10-12 02:14:18 +01:00
Nicholas Boyd Isacsson
913d51af5c Preserve rule order in substitute configuration 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
876dcb9bee Fix substitute test formatting 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
16ac231f7f Refactor substitute tests 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
81b79a08c1 Add test cases for substitute plugin 2024-10-05 15:51:41 +02:00
Karl Besser
37879d0b18 Remove redundant unit tests for ftintitle plugin
Remove redundant unit tests for the `ftintitle.cotains_feat` function
2024-10-01 15:55:38 -05:00
Karl Besser
669307c91c Update ftintitle.contains_feat unit tests
Since the `for_artist` keyword has been removed from
`ftintitle.contains_feat`, the unit tests need to be updated.
This includes the deletion of the test cases that test the
`for_artist=True` delimiters.
2024-09-30 10:28:23 -05:00
Karl-Ludwig Besser
ab86b2d1e8
Merge branch 'beetbox:master' into fix_false_positive_ftintitle 2024-09-30 10:17:19 -05:00
Andrew Rogl
04ee04150a
Reworked #4709 after latest release (#5447)
Fixes #4709 SQL use of Double Quoted Strings.
2024-09-30 10:28:15 +01:00
Karl Besser
6cb2e5926b Add unit tests for separate "feat. X" detection
The unit tests for the `ftintitle.contains_feat` function are now split
up for artist and title matching.
2024-09-26 17:22:25 -04:00
Karl Besser
6c8bd424e8 Add unit tests to test new feat. X detection regex
The previous version of the `plugins.feat_tokens` regular expression
only matched "feat. X" parts if preceded by a space. This caused missed
detections in the `ftintitle.contains_feat` function.
This commit adds unit tests for the updated regex that also matches
"feat. X" parts within parentheses and brackets
2024-09-22 18:30:28 -04:00
Šarūnas Nejus
11fa6c7b3f
Introduce integration_test marker and update testing docs 2024-09-21 13:26:05 +01:00
Šarūnas Nejus
fe4d4921c1
Replace OrderedEnum with a builtin IntEnum
The variable in `test_ordered_enum` was flagged for naming issues, and
I noticed that `OrderedEnum` is essentially `enum.IntEnum`.

I guess `OrderedEnum` exists because it was created before
`enum.IntEnum` was made available in Python 3.4. We do not need it
anymore though, so it's now gone.
2024-09-21 11:59:19 +01:00
Šarūnas Nejus
5f78d1b82b
Remove some lint exclusions and fix the issues
* Replace `noqa` comments in `assert...` method definitions with
  a configuration option to ignore these names.
* Use the `__all__` variable to specify importable items from the
  module, replacing `*` imports and `noqa` comments for unused imports.
* Address issues with poorly named variables and methods by renaming
  them appropriately.
2024-09-21 11:59:19 +01:00
Šarūnas Nejus
f36bc497c8
Fix lint issues
- Fix imports
- Fix pytest issues
- Do not assign lambda as variable
- Use isinstance instead of type to check type
- Rename ambiguously named variables
- Name custom errors with Error suffix
2024-09-21 11:59:18 +01:00
Šarūnas Nejus
85a17ee503
Reformat the codebase 2024-09-21 11:57:48 +01:00
Konstantin
796c9addfb
Fixes TypeError in the Discogs plugin (#5415)
Handles the case when discogs return `None` for format descriptions.

---------

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-09-19 21:27:16 +01:00
Šarūnas Nejus
5785522170
fetchart: defer file removal config option evaluation (#5244)
Defer the evaluation of the source file removal options (`import.delete`
and `import.move`) to the point where the fetchart plugin is actually
called instead of only evaluating those configuration options on plugin
initialization.
This is to allow other plugins (such as the
[ytimport](https://github.com/mgoltzsche/beets-ytimport/blob/v1.8.1/beetsplug/ytimport/__init__.py#L194)
plugin) to invoke the import directly (within the same python process;
implicitly invoking the fetchart plugin) with temporarily overwritten
configuration options.

Addresses
https://github.com/beetbox/beets/issues/5167#issuecomment-2106465172
2024-09-16 11:44:46 +01:00
Šarūnas Nejus
54b2435c72
Update dependencies and do not install reflink on Windows for tests (#5407)
See my comment under #5406 for context

> The build on win32 is failing to install reflink because it's [only
supported until Python
3.7](https://gitlab.com/rubdos/pyreflink/-/blob/master/setup.py?ref_type=heads).
>
> I will address this in a separate PR and rebase this one accordingly
once the fix is merged.
>
> Note: this issue popped up now because I added a new requests-mock
dependency which invalidated cached dependencies.
2024-09-08 12:31:02 +01:00
J0J0 Todos
98f4a88923
ftintitle: New customization option to keep feature in artist field (#5356) 2024-09-06 13:41:15 +02:00
Tânio Scherer
0b067e9f5b Create a new template function: capitalize
Update documentation

Update changelog
2024-09-05 23:00:50 -03:00
Karl-Ludwig Besser
39acba5200
Merge branch 'master' into ftintitle_keep_artist 2024-09-05 12:32:20 +02:00