Commit Graph

14398 Commits

Author SHA1 Message Date
Sebastian Mohr
10b6e423b3 Removed unnecessary str typehint. 2026-05-16 16:18:37 +02:00
Sebastian Mohr
e9dec6e26b Moved to requests_mock fixtures:
- Renamed image_response_mocker to image_request_mock
- Use requests_mock.mocker.Mocker instead of responses.RequestsMock
- Renamed function add to get
2026-05-16 16:14:37 +02:00
Sebastian Mohr
55e13b4e75 Moved PytestTestHelper into test/helper.py 2026-05-16 15:25:17 +02:00
Sebastian Mohr
e5bf2ff6a5 Fixed logic inversion in cleanup fixture. 2026-05-14 19:10:44 +02:00
Sebastian Mohr
22a7714563 Fixed a number of typing issues. 2026-05-14 19:10:44 +02:00
Sebastian Mohr
40cec30ce3 EmbedartCliTest -> TestEmbedartCli
use the new image_response_mocker and pytest setup
2026-05-14 19:10:42 +02:00
Sebastian Mohr
86d60a98a0 TestAAO use image_response_mocker 2026-05-14 19:04:50 +02:00
Sebastian Mohr
a199a002da ArtImporterTest -> TestArtImporter 2026-05-14 19:04:50 +02:00
Sebastian Mohr
ac8c199105 CombinedTest -> TestCombined 2026-05-14 19:04:50 +02:00
Sebastian Mohr
e2c87cec2e TestFetchImage use image_response_mocker 2026-05-14 19:04:50 +02:00
Sebastian Mohr
4a634f191f GoogleImageTest -> TestGoogleImage 2026-05-14 19:04:50 +02:00
Sebastian Mohr
182f8edae2 ITunesStoreTest -> TestITunesStore 2026-05-14 19:04:50 +02:00
Sebastian Mohr
a41d4ca424 FanartTVTest -> TestFanartTV 2026-05-14 19:04:50 +02:00
Sebastian Mohr
4ce27cd34b CoverArtArchiveTest -> TestCoverArtArchive: Uses new
image_response_mocker instead of class inheritance. Aligns more
with pytest imo
2026-05-14 18:42:30 +02:00
Sebastian Mohr
73c1cce63e CAAHelper -> CAAData: The functions here are not needed anymore as they
are now provided by the imageResponseMocker. Also fixed indenting of
json blocks.
2026-05-14 18:42:30 +02:00
Sebastian Mohr
8d633c2735 FetchImageHelper -> ImageResponseMocker Also moved pytest related
fixture into own mixin.
2026-05-14 18:42:30 +02:00
Sebastian Mohr
abc5d209c8 TestDeprecatedConfig -> TestDeprecatedConfig
EnforceRatioConfigTest -> TestEnforceRatioConfig
2026-05-14 18:42:30 +02:00
Sebastian Mohr
34380e8262 AAOTest -> TestAAO 2026-05-14 18:42:29 +02:00
Sebastian Mohr
a4649b6d49 FSArtTest -> TestFSArt 2026-05-14 18:42:29 +02:00
Sebastian Mohr
722e83f874 FetchImageTest -> TestFetchImage 2026-05-14 18:42:29 +02:00
Sebastian Mohr
d7c6ddd621 AlbumArtPerformOperationTest -> TestAlbumArtPerformOperation:
- moved setup into proper pytest fixtures for seperation
2026-05-14 18:42:29 +02:00
Sebastian Mohr
f2362abc55 AlbumArtOperationTestCase -> AlbumArtOperationMixin
AlbumArtOperationConfigurationTest -> TestAlbumArtOperationConfiguration
2026-05-14 18:42:29 +02:00
Sebastian Mohr
915ae7680f Replaced UseThePlugin Unittest class with pytest based setup. 2026-05-14 18:42:29 +02:00
Šarūnas Nejus
5df37abc43 Update deps (#6632)
We have a vulnerability in `urllib3` so here's an upgrade to all deps.

<img width="713" height="368" alt="image"
src="https://github.com/user-attachments/assets/2d72c1e6-09a9-4d06-92d8-9a5759f205f8"
/>

Fixes #6633
2026-05-14 15:07:42 +01:00
Šarūnas Nejus
4acbb0f913 Add dependency extra for tidal 2026-05-14 14:54:40 +01:00
Šarūnas Nejus
d4f7f9ffd5 Fix types 2026-05-14 14:54:40 +01:00
Šarūnas Nejus
a050ba6eca Update dependencies 2026-05-14 14:54:40 +01:00
Sebastian Mohr
1182713baa Refactored test_mb_sync to use pytest and removed capture_log (#6617)
This pull request refactors the `test/plugins/test_mbsync.py` test suite
to use `pytest` fixtures and utilities rather than the previous
unittest-based helpers. It also updates the way logs are captured in
tests to use `pytest`'s `caplog` fixture instead of the custom
`capture_log` context manager.

---

This is part of the multi-step efforts to improve logging in beets
https://github.com/beetbox/beets/issues/6553
2026-05-14 15:52:30 +02:00
Sebastian Mohr
cf97ce87b8 Refactored test_mb_sync to use pytest and removed capture_log in favor
of caplog.
2026-05-14 15:47:00 +02:00
Šarūnas Nejus
544d45a1e9 fix(mbsync): do not clear metadata if import.from_scratch is set (#6625)
if import.from_scratch was set in the config, runnning mbsync would
clear any metadata not provided by MBz (replay gain, lyrics, genres...).
we now ignore this setting when running mbsync to preserve metadata.

Fixes: #6613
2026-05-13 17:57:02 +01:00
ShimmerGlass
65ccaf1408 fix(mbsync): do not clear metadata if import.from_scratch is set
if import.from_scratch was set in the config, runnning mbsync would
clear any metadata not provided by MBz (replay gain, lyrics, genres...).
we now ignore this setting when running mbsync to preserve metadata.

Fixes: #6613
2026-05-13 18:06:08 +02:00
Šarūnas Nejus
030909640c fix(duplicates): output format (#6622)
* The pugin used an empty format string unless `--count` was provided,
resulting in outputs like `: 1`. It now correctly displays duplicated
items.
* `--count` was ignored (aside from above bug), and item count was
always appended to output.

Fixes: https://github.com/beetbox/beets/issues/6476
2026-05-13 12:59:04 +01:00
ShimmerGlass
ec1c25644d fix(duplicates): output format
* the pugin used an empty format string unless --count was provided,
  resulting in outputs like `: 1`. it now correctly displays duplicated
  items.
* --count was ignored (aside from above bug), and item count was always
  appended to output.
2026-05-11 22:43:53 +02:00
J0J0 Todos
7c50f94c60 lastgenre: Test empty last.fm result doesnt wipe (#6608)
Add a test case that proves that issue 5991 is fixed by now.

Closes #5991 .
2026-05-09 09:20:05 +02:00
J0J0 Todos
5f94ca79a3 lastgenre: Test empty last.fm result doesnt wipe
Add a test case that proves that issue 5991 is fixed by now.
2026-05-09 09:11:05 +02:00
Šarūnas Nejus
324877042a fix: mbpseudo issues when applying pseudorelease (#6512)
I have not created an issue for this but I tried to use mbpseudo to
apply this pseudorelease:
https://musicbrainz.org/release/6c100fef-6abf-41c4-bd21-6f9becaaab6c

When doing that I encountered two errors as seen below, this PR should
fix those issues. The second issue was only apparent once the first
issue was fixed.

```
Sending event: import_task_choice
Traceback (most recent call last):
  File "/lsiopy/bin/beet", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/ui/__init__.py", line 1013, in main
    _raw_main(args)
  File "/lsiopy/lib/python3.12/site-packages/beets/ui/__init__.py", line 992, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/lsiopy/lib/python3.12/site-packages/beets/ui/commands/import_/__init__.py", line 131, in import_func
    import_files(lib, byte_paths, query)
  File "/lsiopy/lib/python3.12/site-packages/beets/ui/commands/import_/__init__.py", line 75, in import_files
    session.run()
  File "/lsiopy/lib/python3.12/site-packages/beets/importer/session.py", line 237, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/lsiopy/lib/python3.12/site-packages/beets/util/pipeline.py", line 471, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/lsiopy/lib/python3.12/site-packages/beets/util/pipeline.py", line 336, in run
    out = self.coro.send(msg)
          ^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/util/pipeline.py", line 195, in coro
    task = func(*args, task)
           ^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/importer/stages.py", line 217, in user_query
    _apply_choice(session, task)
  File "/lsiopy/lib/python3.12/site-packages/beets/importer/stages.py", line 323, in _apply_choice
    task.apply_metadata()
  File "/lsiopy/lib/python3.12/site-packages/beets/importer/tasks.py", line 263, in apply_metadata
    self.match.apply_metadata()
  File "/lsiopy/lib/python3.12/site-packages/beets/autotag/hooks.py", line 609, in apply_metadata
    for item, data in self.merged_pairs:
                      ^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/autotag/hooks.py", line 603, in merged_pairs
    (i, ti.merge_with_album(self.info))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/autotag/hooks.py", line 482, in merge_with_album
    album = album_info.raw_data
            ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/functools.py", line 998, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/autotag/hooks.py", line 301, in raw_data
    data = {**super().raw_data}
              ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/functools.py", line 998, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/beets/autotag/hooks.py", line 176, in raw_data
    data = self.__class__(**self.copy())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: PseudoAlbumInfo.__init__() missing 2 required positional arguments: 'pseudo_release' and 'official_release'
```

```
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/martin/personal/src-ext/beets/beets/__main__.py", line 24, in <module>
    main(sys.argv[1:])
    ~~~~^^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/ui/__init__.py", line 1013, in main
    _raw_main(args)
    ~~~~~~~~~^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/ui/__init__.py", line 992, in _raw_main
    subcommand.func(lib, suboptions, subargs)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/ui/commands/import_/__init__.py", line 131, in import_func
    import_files(lib, byte_paths, query)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/ui/commands/import_/__init__.py", line 75, in import_files
    session.run()
    ~~~~~~~~~~~^^
  File "/home/martin/personal/src-ext/beets/beets/importer/session.py", line 237, in run
    pl.run_parallel(QUEUE_SIZE)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/util/pipeline.py", line 471, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/martin/personal/src-ext/beets/beets/util/pipeline.py", line 336, in run
    out = self.coro.send(msg)
  File "/home/martin/personal/src-ext/beets/beets/util/pipeline.py", line 195, in coro
    task = func(*args, task)
  File "/home/martin/personal/src-ext/beets/beets/importer/stages.py", line 217, in user_query
    _apply_choice(session, task)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/importer/stages.py", line 326, in _apply_choice
    task.add(session.lib)
    ~~~~~~~~^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/importer/tasks.py", line 503, in add
    self.album = lib.add_album(self.imported_items())
                 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/library/library.py", line 83, in add_album
    item.add(self)
    ~~~~~~~~^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/library/models.py", line 84, in add
    super().add(lib)
    ~~~~~~~~~~~^^^^^
  File "/home/martin/personal/src-ext/beets/beets/dbcore/db.py", line 717, in add
    self.store()
    ~~~~~~~~~~^^
  File "/home/martin/personal/src-ext/beets/beets/library/models.py", line 74, in store
    super().store(fields)
    ~~~~~~~~~~~~~^^^^^^^^
  File "/home/martin/personal/src-ext/beets/beets/dbcore/db.py", line 659, in store
    tx.mutate(
    ~~~~~~~~~^
        f"INSERT INTO {self._flex_table} "
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        (self.id, key, value),
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/martin/personal/src-ext/beets/beets/dbcore/db.py", line 1039, in mutate
    return self.db._connection().execute(statement, subvals).lastrowid
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
sqlite3.ProgrammingError: Error binding parameter 3: type 'dict' is not supported
```
2026-05-08 13:53:32 +01:00
Šarūnas Nejus
cde2dd139e Merge branch 'master' into fix/mbpseudo-raw-data 2026-05-08 13:38:30 +01:00
Sebastian Mohr
e58d404222 Refactored test_hook to use pytest and removed capture_log (#6618)
This pull request refactors the `test/plugins/test_hook.py` test suite
to use `pytest` fixtures and utilities rather than the previous
unittest-based helpers. It also updates the way logs are captured in
tests to use `pytest`'s `caplog` fixture instead of the custom
`capture_log` context manager.

---

This is part of the multi-step efforts to improve logging in beets
https://github.com/beetbox/beets/issues/6553
2026-05-08 13:54:01 +02:00
Sebastian Mohr
2056cce74b test_hook: Removed capture_log in favor for pytest caplog
Also minor refactor to align with pytest
2026-05-08 13:47:37 +02:00
Martin Caspersen
610443ae9e doc: fix formatting 2026-05-08 12:35:59 +02:00
Martin Caspersen
5342d9bc76 Merge remote-tracking branch 'fork/master' into fix/mbpseudo-raw-data 2026-05-08 12:25:49 +02:00
Mathilde Gilles
48b5dbb0e2 feat(import): add --nomove / -M option (#6615)
## Description

Add `--nomove` / `-M` option to override the `move: yes` config option
during import.

This option is especially useful for reimporting when using players /
music servers like Navidrome that easily loose track of files when they
change path and tags at the same time.
Now one can retag their files without moving them `beet import -M
my-files/`, wait for a rescan, and then `beet move`.

original idea by @snejus 

## To Do

<!--
- If you believe one of below checkpoints is not required for the change
you
are submitting, cross it out and check the box nonetheless to let us
know.
  For example: - [x] ~Changelog~
- Regarding the changelog, often it makes sense to add your entry only
once
reviewing is finished. That way you might prevent conflicts from other
PR's in
that file, as well as keep the chance high your description fits with
the
  latest revision of your feature/fix.
- Regarding documentation, bugfixes often don't require additions to the
docs.
- Please remove the descriptive sentences in braces from the enumeration
below,
  which helps to unclutter your PR description.
-->

- [x] Documentation. (If you've added a new command-line flag, for
example, find the appropriate page under `docs/` to describe it.)
- [x] Changelog. (Add an entry to `docs/changelog.rst` to the bottom of
one of the lists near the top of the document.)
- [ ] Tests. (Very much encouraged but not strictly required.)
2026-05-08 08:53:40 +02:00
ShimmerGlass
45e78473b0 feat(import): add --nomove / -M option 2026-05-07 13:50:40 +02:00
Šarūnas Nejus
7dde183d7d convert: Add types and simplify args parsing (#6573)
## Refactor `ConvertPlugin` to use instance attributes instead of
parameter threading

This PR cleans up the `ConvertPlugin` class by eliminating the pattern
of passing config values as explicit parameters through the call chain.

### What changed

- **Removed `_get_opts_and_config`** — a method that returned a 9-tuple
of config values. All callers unpacked and re-passed these values
explicitly.
- **Config values are now `@cached_property` attributes** on
`ConvertPlugin`: `dest`, `fmt`, `force`, `pretend`, `link`, `hardlink`,
`threads`, `playlist`, `path_formats`.
- **CLI option defaults now set from config**, so
`self.config.set(vars(opts))` in `convert_func` is sufficient to merge
CLI overrides — no more `opts.x or config["x"]` branching in
`_get_opts_and_config`.
- **`get_format` → `command` cached property** returning a typed
`FormatCommand` `NamedTuple`, replacing a free function that accessed
the global `config`.
- **`should_transcode` and `encode`** signatures simplified — `fmt`,
`force`, and `pretend` no longer passed as arguments; methods read from
`self`.
- **`_parallel_convert` and `convert_item`** reduced to `(items,
keep_new)` signatures.
- **Free module-level functions** (`get_format`, `in_no_convert`,
`should_transcode`) removed; equivalent logic now lives as methods,
removing the dependency on the global `config` object.
- Types and `TYPE_CHECKING` imports added throughout; `after_convert`
event registered in `plugins.py`.

### Impact

No behaviour change. The refactor reduces argument surface area
significantly, makes the config read path explicit and testable
per-instance, and eliminates a source of subtle bugs where CLI flags
could silently fall back to wrong defaults.
2026-05-06 15:49:48 +01:00
Šarūnas Nejus
86813678d7 Use pipeline.mutator_stage instead of a Generator 2026-05-06 15:30:51 +01:00
Šarūnas Nejus
ec940e8b61 Remove redundant param provision to encode 2026-05-06 15:30:51 +01:00
Šarūnas Nejus
dd33fef52e Remove redundant param provision to should_transcode 2026-05-06 15:30:51 +01:00
Šarūnas Nejus
e574e86887 Replace get_format with command attribute 2026-05-06 15:30:51 +01:00
Šarūnas Nejus
34772d2684 Replace _get_opts_and_config with attributes 2026-05-06 15:30:50 +01:00
Šarūnas Nejus
ee895efd2d Handle opts using the config 2026-05-06 15:30:10 +01:00