Commit Graph

14564 Commits

Author SHA1 Message Date
Šarūnas Nejus
90099f128d Merge branch 'master' into fix-mpdstats-cli-host 2026-06-04 06:03:48 +01:00
Šarūnas Nejus
c4ed45a168 tests: use setup fixture in TestHelper (#6703)
- Move pytest setup/teardown into shared `TestHelper` via an autouse
`setup` fixture.
- Collapse old pytest-specific helpers into the main helpers by using
`TestHelper` and `PluginTestHelper` as the standard test base classes.
- Update plugin and library tests to use the new shared lifecycle
instead of custom fixtures or manual `setUp`/`tearDown`.
- Rewrite `test/plugins/test_ftintitle.py` to use `PluginTestHelper` and
`configure_plugin`, which removes manual environment wiring and makes
the test flow match other plugin tests.
- Simplify `test/plugins/test_mbcollection.py` by dropping its local
helper fixture and relying on the shared test setup.

## High-level impact

- Test architecture becomes more consistent: one shared pytest setup
path instead of many local patterns.
- Boilerplate goes down across the test suite, so future tests should be
easier to write and maintain.
- Deprecated helper split is reduced, which makes test utilities simpler
to understand.
- Main behavior change is in test infrastructure, and it fixes the
failing `ftintitle` and `mbcollection` tests without changing production
plugin logic.
2026-06-03 18:36:02 +01:00
Šarūnas Nejus
dca1b22df2 Add commit to git-blame-ignore-revs 2026-06-03 18:06:09 +01:00
Šarūnas Nejus
5804a21620 Fix autobpm tests 2026-06-03 18:00:46 +01:00
Šarūnas Nejus
ca8544d4bc Fix ftintitle tests 2026-06-03 18:00:46 +01:00
Šarūnas Nejus
544ea3af5d Fix mbcollection tests 2026-06-03 18:00:46 +01:00
Šarūnas Nejus
7bad226c33 Add setup fixture to TestHelper 2026-06-03 18:00:46 +01:00
Šarūnas Nejus
0786ea8e5c autotagging: tidy up autotag module (#6687)
### What changed
- Move `Match`, `AlbumMatch`, and `TrackMatch` from
`beets.autotag.hooks` into `beets.autotag.match`.
- Expand `beets.autotag.__init__` to re-export main autotag types and
functions like `Distance`, `Info`, `Match`, `assign_items`, `tag_album`,
and `tag_item`.
- Update internal code, plugins, tests, and docs to import from
`beets.autotag` instead of reaching into deeper modules.

### Architecture impact
- `beets.autotag` now acts as the main public API for autotagging.
- `hooks.py` stays focused on metadata/info structures.
- `match.py` now owns match objects and matching behavior in one place.

### High-level benefit
- Import paths become simpler and more consistent.
- Internal module boundaries are clearer.
- Future refactors inside autotag should be safer because callers depend
on `beets.autotag`, not module internals.
2026-06-03 16:15:52 +01:00
Šarūnas Nejus
fb9de7a619 lyrics: fix musica parsing 2026-06-03 15:42:19 +01:00
Šarūnas Nejus
5a22b40735 lyrics: introduce apply_methods 2026-06-02 15:46:43 +01:00
Šarūnas Nejus
33653ceffc Update git-blame-ignore-revs 2026-06-02 08:59:43 +01:00
Šarūnas Nejus
fd46e5b773 Move Match classes to beets.autotag.match 2026-06-02 08:57:35 +01:00
Šarūnas Nejus
29580d2f00 Import everything from parent beets.autotag 2026-06-02 08:57:35 +01:00
Sebastian Mohr
8b3f1fb552 refactor: Pytest based setup for test_library (#6677)
## Description

This PR is a refactor of `test/test_library.py` and replaces the unitest
test cases with a pytest setup. Also replaced capture_log with caplog
fixture.

Needs rebasing after https://github.com/beetbox/beets/pull/6659 is
merged.

TODOs:
- [x] ~~Changelog~~ Not needed as this is an internal refactor only
---
This is related to the multi-step efforts to improve logging in beets
https://github.com/beetbox/beets/issues/6553
2026-06-01 19:47:21 +02:00
Sebastian Mohr
0c42b34c62 Added git blame ignore rev entry and formatting. 2026-06-01 19:41:51 +02:00
Sebastian Mohr
c6dc99f565 Remove i = with item = for consistency. 2026-06-01 19:41:51 +02:00
Sebastian Mohr
d226a930fe TestItemRead: Aligned with PytestItemHelper 2026-06-01 19:41:51 +02:00
Sebastian Mohr
be0eb1439b TestPathString: Use get_first_item helper function. Also consistency
renaming i -> item
2026-06-01 19:41:51 +02:00
Sebastian Mohr
c37ae7fe6e TestAlbumInfo: Renamed item fixture to item_in_album, should reflect intend
more closely.
2026-06-01 19:41:51 +02:00
Sebastian Mohr
50ca216881 Removed self.i in favor of more pytest like item and item_in_db fixtures. 2026-06-01 19:41:51 +02:00
Sebastian Mohr
fda0a68d35 Fixed teardown logic and removed unnecessary imports. 2026-06-01 19:41:51 +02:00
Sebastian Mohr
27f4092fdb TemplateTest -> TemplateTest 2026-06-01 19:41:51 +02:00
Sebastian Mohr
a7a789d9ee UnicodePathTest -> TestUnicodePath 2026-06-01 19:41:51 +02:00
Sebastian Mohr
31248cb813 ItemPruneDirsClutterTest -> TestItemPruneDirsClutter 2026-06-01 19:41:51 +02:00
Sebastian Mohr
870a236b53 FilesizeTest -> TestFilesize 2026-06-01 19:41:51 +02:00
Sebastian Mohr
69fdf15e9f WriteTest -> TestWrite, ItemReadTest -> TestItemRead, ItemReadGenreTest -> TestItemReadGenre 2026-06-01 19:41:51 +02:00
Sebastian Mohr
d67263408e ImportTimeTest -> TestImportTime 2026-06-01 19:41:51 +02:00
Sebastian Mohr
075b230266 MtimeTest -> TestMtime 2026-06-01 19:41:51 +02:00
Sebastian Mohr
2897df99a9 PathStringTest -> TestPathString 2026-06-01 19:41:51 +02:00
Sebastian Mohr
f91f6b849a ArtDestinationTest -> TestArtDestination 2026-06-01 19:41:51 +02:00
Sebastian Mohr
3dfbcb26e0 AlbumInfoTest -> TestAlbumInfo 2026-06-01 19:41:51 +02:00
Sebastian Mohr
6fc1d34c9a PluginDestinationTest -> TestPluginDestination 2026-06-01 19:41:51 +02:00
Sebastian Mohr
016445d851 SingletonDisambiguationTest -> TestSingletonDisambiguation 2026-06-01 19:41:51 +02:00
Sebastian Mohr
d3892b81e9 DisambiguationTest -> TestDisambiguation 2026-06-01 19:41:51 +02:00
Sebastian Mohr
3e967a93bf DestinationFunctionTest -> TestDestinationFunction 2026-06-01 19:41:51 +02:00
Sebastian Mohr
02bee3a468 ItemFormattedMappingTest -> TestItemFormattedMapping 2026-06-01 19:41:51 +02:00
Sebastian Mohr
c9249464cb ParseQueryTest -> TestParseQuery 2026-06-01 19:41:51 +02:00
Sebastian Mohr
733249912a DestinationTest -> TestDestination 2026-06-01 19:41:51 +02:00
Sebastian Mohr
eef0fefbd9 GetSetTest -> TestGetSet 2026-06-01 19:41:51 +02:00
Sebastian Mohr
b3ed48e1b5 RemoveTest -> TestRemove 2026-06-01 19:41:51 +02:00
Sebastian Mohr
a46bb52168 AddTest -> TestAdd:
Also PytestItemHelper for item fixture without db binding.
2026-06-01 19:41:51 +02:00
Sebastian Mohr
8368d0a6c1 StoreTest -> TestStore 2026-06-01 19:41:51 +02:00
Sebastian Mohr
9db2860877 LoadTest -> TestLoad:
Also introduced PytestItemInDBHelper for item fixture.
2026-06-01 19:41:51 +02:00
Tsuizxgo
cf7c5e4eb2 Fix mpdstats CLI option overrides 2026-06-01 23:57:07 +08:00
Sebastian Mohr
52a7ba684e spotify: batch spotifysync DB commit (#6673)
This is a follow-up to #6485. Currently `spotifysync`:
- batches Spotify HTTP requests, but still stores each item individually
- writes to the DB before writing tags
- logs Audio features API unavailable, skipping once per remaining item
after a 403

This makes logs noisy and causes unnecessary DB commit overhead.

This PR :
- keeps the existing batched Spotify API fetches
- batches `spotifysync` database persistence into a single outer DB
transaction per run
- aligns `spotifysync` with the normal beets write-before-store pattern
- suppresses repeated per-item audio-features unavailability log spam

Actual logs before fix (masked):
```bash
$ beet -v spotifysync -f album:"ALBUM"
...
spotify: Total 5 tracks
spotify: Processing 1/5 tracks - <Album A> - <Track 1>
spotify: Processing 2/5 tracks - <Album A> - <Track 2>
spotify: Processing 3/5 tracks - <Album A> - <Track 3>
spotify: Processing 4/5 tracks - <Album A> - <Track 4>
spotify: Processing 5/5 tracks - <Album A> - <Track 5>
spotify: Audio features API is unavailable (403 error). Skipping audio features for remaining tracks.
spotify: Audio features API unavailable, skipping
Sending event: database_change
Sending event: write
Sending event: after_write
spotify: Audio features API unavailable, skipping
Sending event: database_change
Sending event: write
Sending event: after_write
spotify: Audio features API unavailable, skipping
Sending event: database_change
Sending event: write
Sending event: after_write
spotify: Audio features API unavailable, skipping
Sending event: database_change
Sending event: write
Sending event: after_write
spotify: Audio features API unavailable, skipping
Sending event: database_change
Sending event: write
Sending event: after_write
```
Logs after fix (masked)):
```bash
$ beet -v spotifysync -f album:"ALBUM"
...
spotify: Total 5 tracks
spotify: Processing 1/5 tracks - <Album A> - <Track 1>
spotify: Processing 2/5 tracks - <Album A> - <Track 2>
spotify: Processing 3/5 tracks - <Album A> - <Track 3>
spotify: Processing 4/5 tracks - <Album A> - <Track 4>
spotify: Processing 5/5 tracks - <Album A> - <Track 5>
spotify: Audio features API is unavailable (403 error). Skipping audio features for remaining tracks.
Sending event: write
Sending event: after_write
Sending event: write
Sending event: after_write
Sending event: write
Sending event: after_write
Sending event: write
Sending event: after_write
Sending event: write
Sending event: after_write
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
```

- [x] Changelog. (Add an entry to `docs/changelog.rst` to the bottom of
one of the lists near the top of the document.)
- [x] Tests. (Very much encouraged but not strictly required.)
2026-06-01 10:52:36 +02:00
Alok Saboo
672addeff4 remove capture_log 2026-06-01 10:46:57 +02:00
Alok Saboo
f8a834fb7a add typehints 2026-06-01 10:46:57 +02:00
Alok Saboo
b7b2449371 simplify test 2026-06-01 10:46:57 +02:00
Alok Saboo
a333b307e3 remove optional test 2026-06-01 10:46:57 +02:00
Alok Saboo
4b554e9697 Batch SQLite commits and follow write-before-store pattern 2026-06-01 10:46:57 +02:00