Commit Graph

3734 Commits

Author SHA1 Message Date
Šarūnas Nejus
8261f72628 Skip tests that fail due to Windows path handling 2026-07-13 18:43:23 +01:00
Šarūnas Nejus
92d90e01d3 Refactor queryparse tests 2026-07-13 18:43:22 +01:00
Šarūnas Nejus
6b568ebd7e Simplify imports in test_queryparse.py 2026-07-13 18:43:22 +01:00
Šarūnas Nejus
471d7f3791 Replace queryparse functions with ModelQuery helpers
- Move query and sort construction into `ModelQuery` classmethods and parse
  tokenized input once.
- Switch call sites to consume `parse_query(...).query` and
  `parse_query(...).sort` instead of tuple unpacking.
- Remove legacy `dbcore` re-exports and obsolete helper functions in
  `queryparse`.
- Update query/sort tests to match the new parsing behavior and simplified
  query object shapes.
2026-07-13 18:43:22 +01:00
Šarūnas Nejus
aa2cd9bf03 Simplify parse_sorted_query 2026-07-13 18:43:22 +01:00
Šarūnas Nejus
5cb0fadbcf Rename query_from_strings -> build_and_query 2026-07-13 18:43:22 +01:00
Šarūnas Nejus
982435e8b8 Do not wrap single query with AndQuery 2026-07-13 18:43:22 +01:00
Šarūnas Nejus
2b7be8175c Replace parse_query_string, parse_query_parts by ModelQuery.parse
- Add ModelQuery in dbcore.queryparse and expose LibModel.parse_query as
  the single parsing entrypoint for string and sequence query inputs.
- Route library fetch, path format matching, and plugin query parsing
  through the model-level API, and deprecate
  beets.library.parse_query_string and parse_query_parts.
- Update tests to cover invalid query parsing via ModelQuery and align
  smartplaylist sort assertions with parsed sort behavior.
2026-07-13 18:43:22 +01:00
Šarūnas Nejus
d9ca7ec19b Replace parse_query_part with QueryTerm
- Replace parse_query_part with a QueryTerm parser that captures negate, field,
  prefix, and pattern in one pass.
- Resolve query class selection through QueryTerm so prefix and field-based
  dispatch are handled consistently.
- Move implicit path query normalization into dbcore parsing, simplifying
  library-level query parsing.
- Tighten plugin query typing and update dbcore tests for path behavior and
  related fixture assertions.
2026-07-13 18:43:21 +01:00
Šarūnas Nejus
f6621ffa1a Read sort case sensitivity in FieldSort
Move sort case-sensitivity config lookup into `FieldSort` as a cached
class property instead of threading a `case_insensitive` flag through
query parsing helpers.

This centralizes sort behavior at the sort implementation boundary and
simplifies parse/orchestration call paths while preserving configurable
case-sensitive ordering.
2026-07-13 18:39:40 +01:00
Šarūnas Nejus
8e62d66474 dbcore: rename Database._fetch to Database.get_results
This removes ambiguity with Library._fetch
2026-07-13 18:39:40 +01:00
Šarūnas Nejus
0e796d46c1 Move prefixes to where they are used 2026-07-13 18:39:40 +01:00
Alok Saboo
01c2943e76 remove redundant test 2026-07-13 12:37:07 -04:00
Alok Saboo
3ce00617e9 switch the logic ot strip item-only fixed fields 2026-07-13 12:29:55 -04:00
Alok Saboo
58fb167750 Merge branch 'master' into edit 2026-07-13 08:47:53 -04:00
TowyTowy
2293d2f60a Fix crash when sorting by a nullable field missing on some items
Sorting by a field whose declared type is nullable (its null value is
`None`, e.g. `NullInteger`/`NullFloat`) raised `TypeError: '<' not
supported between instances of ...` when the field was present on some
objects but missing on others, because `FieldSort.sort` compared `None`
against real values.

Group missing values together in the sort key so they are never compared
against present ones: they are ordered first when sorting ascending and
last when descending, matching SQLite's default ordering of NULLs used by
the fast `FixedFieldSort` path.

Fixes #3461.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-13 13:36:23 +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
Alok Saboo
7f45f51690 Merge branch 'master' into edit 2026-07-12 20:39:16 -04:00
Šarūnas Nejus
d9a1bde1c9 Add --no-keep-synced CLI option to lyrics
- Allow manual lyrics fetches to override keep_synced configuration for a single
  run.
2026-07-13 01:14:41 +01:00
Alok Saboo
aeaab7320d Merge branch 'master' into edit 2026-07-12 20:14:33 -04:00
Alok Saboo
210ca09637 ignore item-only fields configured in albumfields 2026-07-12 20:14:11 -04:00
Šarūnas Nejus
95854c7770 Add a migration 2026-07-13 01:07:59 +01:00
Šarūnas Nejus
8020c07acf Track instrumental lyrics metadata
- Leave lyrics text empty when a backend reports an instrumental track and
  persist that state in lyrics_instrumental.
2026-07-13 01:07:59 +01:00
Alok Saboo
f91ba3a315 Merge branch 'master' into edit 2026-07-12 09:12:02 -04:00
Alok Saboo
55199bf365 harden edit-plugin id matching against duplicate ids and header reordering 2026-07-10 17:52:55 -04:00
Ross Williams
6afc0f282a test: add importer test for fetchart plugin
Test whether fetchart is run during the import phase and, specifically,
whether the `fetch_for_asis` setting is honored. Mock boundary is
between `FetchArtPlugin` and `ArtSource`, an already-existing internal
API boundary.
2026-07-10 22:19:44 +01:00
Ross Williams
77405266eb test: convert test_fetchart to TestHelper
Signed-off-by: Ross Williams <ross@ross-williams.net>
2026-07-10 22:15:39 +01:00
Alok Saboo
094e38e002 Merge remote-tracking branch 'upstream/master' into edit
# Conflicts:
#	docs/changelog.rst
2026-07-10 16:31:13 -04:00
Alok Saboo
855434792c refactor code to remove duplication 2026-07-10 08:27:24 -04:00
Alok Saboo
c30dd28238 address reviewer comment; match track to items by id 2026-07-10 08:27:24 -04:00
Alok Saboo
bf94ae66ef sync branch 2026-07-10 08:27:23 -04:00
Trey Turner
5d2280013a test(ftintitle): remove mostly redundant test_trackinfo_received_preserves_collaborative_artist_credit 2026-07-08 22:02:12 -05:00
Trey Turner
617bfd6a92 fix(ftintitle): remove singleton handling as out of scope 2026-07-08 21:53:00 -05:00
Trey Turner
6132297fa1 test(ftintitle): remove item_data["artist"] assertion from artist_credit test 2026-07-08 21:53:00 -05:00
Trey Turner
b88390fc32 refactor(ftintitle): abstract ft_in_info into ft_in_title 2026-07-08 21:52:52 -05:00
Trey Turner
5738a8a0f1 test(ftintitle): remove artist_credit tests 2026-07-08 21:10:48 -05:00
Trey Turner
9abe96355b fix(ftintitle): defer inclusion of artist_credit, review cleanup 2026-07-08 21:10:48 -05:00
Trey Turner
61f8c94e7f fix(hooks): remove cached property invalidation 2026-07-08 21:10:48 -05:00
Trey Turner
1160d31cfa feat(ftintitle): hook metadata events, fixing mbsync 2026-07-08 21:10:47 -05:00
dong
7cc3e0b5a4 Support multi-value modify operators 2026-07-08 12:12:15 +01:00
Šarūnas Nejus
230bf19c7f Remove redundant test logic exposed by full coverage
- Removing the coverage omit configuration exposed unused branches, helpers, and
  fixtures across the test suite.
- Delete that redundant logic and simplify affected tests while preserving their
  behavior.
2026-07-07 15:57:35 +01:00
Šarūnas Nejus
79c7d69311 Remove wrongly added copyright markers 2026-07-07 15:57:35 +01:00
Šarūnas Nejus
7cf8896597 Make the global config fixture function-scoped 2026-07-03 21:21:19 +01:00
Šarūnas Nejus
7c8924d8c9 Cache config.source in ConfigMixin for test speedup 2026-07-03 21:21:19 +01:00
Šarūnas Nejus
8968648341 Update asciification tests 2026-07-03 18:59:19 +01:00
Šarūnas Nejus
89a831613a Centralize path asciification normalization
- Move Unicode normalization and separator replacement into util.asciify_path.
- Update library callers and relocate focused asciify tests to util coverage.
2026-07-03 18:59:19 +01:00
Temitope S Olugbemi
65a01c2c2a fix(importfeeds): keep import going when a symlink can't be created
When `formats` includes `link`, importfeeds creates a symlink per imported
item. A failed symlink (lacking privilege on Windows, a read-only directory, or
a filesystem without symlink support) raised beets.util.FilesystemError out of
the import pipeline and aborted the whole `beet import` run, even though the
tracks were already imported.

Catch FilesystemError around the link() call, log a per-item warning, and
continue with the remaining items. Add regression tests for the
warn-and-continue behaviour, that only FilesystemError is caught, and that a
successful link still creates the symlink. Add a changelog entry.

Fixes #840.
2026-07-03 10:26:17 -07:00
Šarūnas Nejus
aef9c64cb0 Move DummyIMBackend to fixtures 2026-06-30 21:48:40 +01:00
Šarūnas Nejus
900543baca Move test modules under folders that they belong to 2026-06-30 21:48:40 +01:00
Šarūnas Nejus
816cddbfd5 Define DB fixtures in a shared place 2026-06-30 21:39:34 +01:00