Commit Graph

31 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
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
Š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
900543baca Move test modules under folders that they belong to 2026-06-30 21:48:40 +01:00
Sebastian Mohr
54a2bd20e1 Removed This file is part of beets... headers. 2026-06-29 11:20:15 +02:00
Šarūnas Nejus
de5c690181 Use class-scoped config across the test module 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
af1e6ceb4d Remove duplicate branches 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
31f7cd4360 Tighten config sort tests
- Combine default and override sort assertions for items and albums.
- Use the config fixture and exact ordered results to avoid global config state.
2026-06-24 17:01:19 +01:00
Šarūnas Nejus
616b1b2b0b Refactor TestNonExistingField
- Consolidate duplicate sort test coverage with parametrized cases.
- Keep missing-field and mixed-presence behavior covered while reducing repeated
  assertions.
2026-06-24 17:01:19 +01:00
Šarūnas Nejus
85e4c607d2 Simplify TestCaseSensitivity 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
fb812daebe Simplify paths 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
eb07fa3a40 Consolidate sort query tests
- Replace duplicate direct MultipleSort checks with parametrized query-string
  cases covering single-field, multi-field, fixed, flex, and computed sort
  behavior.
- Reduce test repetition while keeping the same sort behavior coverage.
2026-06-24 17:01:19 +01:00
Šarūnas Nejus
349b082232 Parametrize descending sort coverage 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
2d98777205 Parametrize ascending sort coverage
- Consolidate duplicate ascending sort tests across item and album fixed and
  flexible fields.
2026-06-24 17:01:19 +01:00
Šarūnas Nejus
da1969125b Only set required fields 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
100a645ffa Use pytest 2026-06-24 17:01:19 +01:00
Šarūnas Nejus
0cd20798aa sort: Update dotted sort references 2026-05-17 07:39:13 +01:00
Šarūnas Nejus
2db5383850 Move test_sort.py under test/dbcore 2026-05-17 07:39:13 +01:00