Commit Graph

74 Commits

Author SHA1 Message Date
Šarūnas Nejus
bfd3b7e04a Make RSRC a pathlib.Path 2026-07-21 16:23:49 +01:00
Šarūnas Nejus
d24c0d341e Rename PathsMixin.temp_dir_path to PathsMixin.temp_path for consistency 2026-07-21 11:15:25 +01:00
Šarūnas Nejus
2e9ace7b20 Replace PathsMixin.temp_dir attribute with PathsMixin.temp_dir_path 2026-07-21 11:15:25 +01:00
Šarūnas Nejus
dc2826fa4b Replace TestHelper.libdir attribute with TestHelper.lib_path 2026-07-21 11:15:25 +01:00
Ross Williams
c2fc7a8a57 test: fix requests_mock setup in test_art.py
`requests_mock` was configured with a fallback matcher to return an
exception on any request. The intent was to have tests fail if any
requests are attempted in tests without matching mocks. This is the
default behavior of `requests_mock`, so no fallback matcher is
necessary. The side-effect of the fallback matcher, removed by this
commit, was that 1) the `NoMockAddress` exception was raised to the
function under test rather than to the test harness and 2) the
`NoMockAddress` exception was not able to be constructed because the
`exc` parameter to `requests_mock.register_uri` does not support
exceptions that require arguments. This behavior is visible in the
following log snippet, taken from an incorrectly-passing test:

```
DEBUG    beets.fetchart:logging.py:163 downloading image: https://images.amazon.com/images/P/xxxx.01.LZZZZZZZ.jpg
DEBUG    requests_mock.adapter:adapter.py:256 GET https://images.amazon.com/images/P/xxxx.01.LZZZZZZZ.jpg 200
DEBUG    beets.fetchart:logging.py:163 not a supported image: text/html
DEBUG    beets.fetchart:logging.py:163 downloading image: https://images.amazon.com/images/P/xxxx.02.LZZZZZZZ.jpg
DEBUG    beets.fetchart:logging.py:163 error fetching art: NoMockAddress.__init__() missing 1 required positional argument: 'request'
```

The test that emitted these logs passed because the `FetchArt` plugin is
written to handle exceptions raised by art sources, skipping and logging
an error. For the exception to cause a failing test, the default
behavior of `requests_mock` of raising an exception to the test harness
when no matching mock requests can be found must be allowed.

Signed-off-by: Ross Williams <ross@ross-williams.net>
2026-07-13 13:21:32 +01:00
Sebastian Mohr
54a2bd20e1 Removed This file is part of beets... headers. 2026-06-29 11:20:15 +02:00
Šarūnas Nejus
3b9034e8cf Only skip tests not in CI 2026-06-13 01:46:44 +01:00
Šarūnas Nejus
4f3ac5a40a Exclude artresizer tests when unavailable 2026-06-13 01:46:44 +01:00
Šarūnas Nejus
7bad226c33 Add setup fixture to TestHelper 2026-06-03 18:00:46 +01:00
Šarūnas Nejus
29580d2f00 Import everything from parent beets.autotag 2026-06-02 08:57:35 +01:00
Sebastian Mohr
53060a4ba0 Reformatted 2026-05-21 16:55:05 +02:00
Sebastian Mohr
f7114266a4 Fold lines. 2026-05-21 16:54:50 +02:00
Sebastian Mohr
96a96bb4ec Removed typehints 2026-05-21 16:54:50 +02:00
Sebastian Mohr
39b1e21904 Removed unnecessary str typehint. 2026-05-21 16:54:50 +02:00
Sebastian Mohr
d90f22f8e5 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-21 16:54:50 +02:00
Sebastian Mohr
59ba8ad21b Moved PytestTestHelper into test/helper.py 2026-05-21 16:54:50 +02:00
Sebastian Mohr
2fea2efc4a Fixed logic inversion in cleanup fixture. 2026-05-21 16:54:50 +02:00
Sebastian Mohr
65bceb4f49 Fixed a number of typing issues. 2026-05-21 16:54:50 +02:00
Sebastian Mohr
f3c1663536 TestAAO use image_response_mocker 2026-05-21 16:54:50 +02:00
Sebastian Mohr
349fcce72a ArtImporterTest -> TestArtImporter 2026-05-21 16:54:50 +02:00
Sebastian Mohr
0172436592 CombinedTest -> TestCombined 2026-05-21 16:54:50 +02:00
Sebastian Mohr
30898f7dfd TestFetchImage use image_response_mocker 2026-05-21 16:54:50 +02:00
Sebastian Mohr
5d427aa159 GoogleImageTest -> TestGoogleImage 2026-05-21 16:54:50 +02:00
Sebastian Mohr
8e919fd4f8 ITunesStoreTest -> TestITunesStore 2026-05-21 16:54:50 +02:00
Sebastian Mohr
e59f2f9047 FanartTVTest -> TestFanartTV 2026-05-21 16:54:50 +02:00
Sebastian Mohr
45bb25741c CoverArtArchiveTest -> TestCoverArtArchive: Uses new
image_response_mocker instead of class inheritance. Aligns more
with pytest imo
2026-05-21 16:54:50 +02:00
Sebastian Mohr
91d5f5aef8 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-21 16:54:39 +02:00
Sebastian Mohr
da3285d0d9 TestDeprecatedConfig -> TestDeprecatedConfig
EnforceRatioConfigTest -> TestEnforceRatioConfig
2026-05-21 16:54:29 +02:00
Sebastian Mohr
b62ba96fd0 AAOTest -> TestAAO 2026-05-21 16:54:29 +02:00
Sebastian Mohr
6e72c50758 FSArtTest -> TestFSArt 2026-05-21 16:54:29 +02:00
Sebastian Mohr
83bb069968 FetchImageTest -> TestFetchImage 2026-05-21 16:54:29 +02:00
Sebastian Mohr
4d2b097716 AlbumArtPerformOperationTest -> TestAlbumArtPerformOperation:
- moved setup into proper pytest fixtures for seperation
2026-05-21 16:54:29 +02:00
Sebastian Mohr
efb35782a9 AlbumArtOperationTestCase -> AlbumArtOperationMixin
AlbumArtOperationConfigurationTest -> TestAlbumArtOperationConfiguration
2026-05-21 16:54:29 +02:00
Sebastian Mohr
402b814b4e Replaced UseThePlugin Unittest class with pytest based setup. 2026-05-21 16:54:29 +02:00
Sebastian Mohr
adfb73b66d Run ruff format 2026-05-20 16:53:06 +02:00
Šarūnas Nejus
ccdccdfa8d Remove slow_test unittest marker 2026-04-22 21:47:16 +01:00
Šarūnas Nejus
b8def07121 autotag: use explicit imports 2026-03-28 12:26:27 +00:00
Šarūnas Nejus
5fad834ad2 Ensure we use Distance to initialise Match objects 2026-03-22 19:23:53 +00:00
Danny Trunk
974d917df4 fix(fetchart): prevent deletion of configured fallback cover art
When `import.delete` or `import.move` is enabled, the `assign_art` method calls `task.prune(candidate.path)` unconditionally.
This incorrectly deletes the configured `fetchart.fallback` file.
Add explicit check to skip pruning when the candidate path matches the configured fallback.
2026-03-02 18:10:19 +01:00
Danny Trunk
9ddddf4c39 fetchart: Add support for configurable fallback cover art 2025-12-30 13:45:03 +01:00
Šarūnas Nejus
1c16b2b308 Replace string concatenation (' + ')
- Join hardcoded strings
- Replace concatenated variables with f-strings
2025-08-30 23:10:15 +01:00
Šarūnas Nejus
4a361bd501 Replace format calls with f-strings 2025-08-30 18:42:26 +01:00
Šarūnas Nejus
8dcc69e6d8 Replace _assert_image_operated 2025-07-09 09:21:52 +01:00
Šarūnas Nejus
9f6d5063d1 Replace _assertImageIsValidArt 2025-07-09 09:21:51 +01:00
Šarūnas Nejus
31dbd51222 Replace assertExists and assertNotExist 2025-07-09 09:21:49 +01:00
Šarūnas Nejus
e40c7fd71c Introduce Album.art_filepath to simplify existence checks 2025-07-09 09:21:47 +01:00
Šarūnas Nejus
c9f98fca55 Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
wisp3rwind
a6f2389aed typing: fetchart + tests 2025-05-20 08:57:30 +02: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