198 Commits

Author SHA1 Message Date
oxms16
c9e6d0f84c Fix path queries for multi-valued fields 2026-05-14 12:26:48 +08:00
Šarūnas Nejus
409f4bd19c Fix path tests on Windows 2026-04-11 13:02:42 +01:00
Šarūnas Nejus
d259c3ac73 Store paths relative to music dir in DB, expand on read
Move path relativization/expansion logic from Item._setitem/__getitem__
into dbcore layer (PathType.to_sql/from_sql and PathQuery), so all
models benefit without per-model overrides.

Propagate contextvars to pipeline and replaygain pool threads so the
library root context variable is available during background processing.
2026-04-11 13:01:41 +01:00
Šarūnas Nejus
e3ec808491 Use context to share music_dir 2026-04-11 13:01:41 +01:00
Šarūnas Nejus
02be9b277d Handle legacy fields in modify and queries 2026-04-07 10:42:56 +01:00
Wouter2devries
1930a1d9d7 Fixed Linting 2026-03-26 09:40:17 +01:00
Wouter2devries
0e83f1395a Parameterized the 2 tests into one 2026-03-26 09:34:19 +01:00
Wouter2devries
97a70babf0 Updated tests to test the behaviour
Removed the return boolean test as it already tests for both true and false.
2026-03-20 21:51:55 +01:00
Wouter2devries
867d17e409 Changed has_images to has_cover_art
Per suggestion as this is what used everywhere else
2026-03-20 21:03:52 +01:00
Wouter2devries
1c30e67e03 Added Images query tests, docs and changelog 2026-03-20 14:48:23 +01:00
Šarūnas Nejus
a8d53f78de Fix the rest of the tests 2026-02-27 18:34:26 +00:00
Šarūnas Nejus
09b22949c0 Refactor test_query
And rewrite test_query.py
2025-07-06 16:15:30 +01:00
Šarūnas Nejus
2c6f314f4f Replace assertNegationProperties 2025-07-06 16:15:29 +01:00
Šarūnas Nejus
2b306de0fe Replace assertInResult and assertNotInResult 2025-07-06 16:15:29 +01:00
Šarūnas Nejus
8937978d5f Refactor PathQuery and add docs 2025-07-06 16:09:50 +01:00
Šarūnas Nejus
45f92ac641 Remove case_sensitive from PathQuery.__init__
The case_sensitive parameter was only used in tests, which now use
monkeypatch to control the behavior of util.case_sensitive() instead.
This simplifies the PathQuery initialization logic while maintaining
test coverage.
2025-07-06 16:09:50 +01:00
Šarūnas Nejus
a38918380d Rewrite path query tests using pytest.mark.parametrize
And remove `force_implicit_query_detection` attribute from `PathQuery`
class.
2025-07-06 16:09:49 +01:00
Šarūnas Nejus
1a045c9166 Copy paste query, types from library to dbcore 2025-07-06 16:03:46 +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
Šarūnas Nejus
d22c497dc0 Use table-qualified names in any field query
In order to include the table name for fields in this query, use the
`field_query` method.

Since `AnyFieldQuery` is just an `OrQuery` under the hood, remove it and
construct `OrQuery` explicitly instead.
2025-01-19 01:09:11 +00:00
valrus
80a10c7e4e lint 2024-12-31 15:14:32 -08:00
valrus
21c734bff8 patch rather than overwriting Item 2024-12-31 14:50:44 -08: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
85a17ee503 Reformat the codebase 2024-09-21 11:57:48 +01:00
Šarūnas Nejus
4b69b493d2 Use f-string syntax 2024-08-16 17:47:23 +01:00
Šarūnas Nejus
f9359df0d1 Replace assertNotEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
847e3858a6 Replace assertRaises 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
9a05d27acf Replace assertEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
6631b6aef6 Replace assertNotIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
11e948121c Replace assertIn 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
5d4911e905 Replace assertIsNone 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
cb82917fe0 Replace assertFalse 2024-08-12 08:43:41 +01:00
Šarūnas Nejus
0ecc345143 Replace assertTrue 2024-08-05 17:11:16 +01:00
Šarūnas Nejus
fcff5d72af Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00
Šarūnas Nejus
7d7f16395c Remove redundant library setUp instructions 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
b64eaeda0a Rename LibTestCase to ItemInDBTestCase 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
6c1e26acc9 Replace unittest.TestCase, TestHelper by BeetsTestCase 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
3e278159ed Dedupe TestHelper and _common.TestCase setup 2024-07-28 18:58:33 +01:00
Šarūnas Nejus
bcc2826000 Make sure we can filter common fields 2024-06-21 15:05:29 +01:00
Šarūnas Nejus
981a61bd56 Add support for filtering relations 2024-06-21 15:05:29 +01:00
Šarūnas Nejus
2800a323a2 Revert "Make queries fast, filter all flexible attributes (#5240)"
This reverts commit 143b9202f3, reversing
changes made to 8508a57d77.
2024-06-19 21:51:44 +01:00
Šarūnas Nejus
6792a75c7e Ensure that any field query uses the table name
In order to include the table name for fields in this query, use the
`field_query` method.

Since `AnyFieldQuery` is just an `OrQuery` under the hood, remove it and
construct `OrQuery` explicitly instead.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
9207b17d13 Enable querying related flexible attributes
Unify query creation logic from
- queryparse.py:construct_query_part,
- Model.field_query,
- DefaultTemplateFunctions._tmpl_unique

to a single implementation under `LibModel.field_query` class method.
This method should be used for query resolution for model (flex)fields.

Allow filtering item attributes in album queries and vice versa by
merging `flex_attrs` from Album and Item together as `all_flex_attrs`.
This field is only used for filtering and is discarded after.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
484c00e223 Add ability to filter flexible attributes through the Query
For a flexible attribute query, replace the `col_name` property with
a function call that extracts that attribute from the `field_attrs`
field introduced in the earlier commit.

Additionally, for boolean, numeric and date queries CAST the value to
NUMERIC SQLite affinity to ensure that our queries like 'flex:1..5' and
'flex:true' continue working fine.

This removes the concept of 'slow query', since every query for any
field now has an SQL clause.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
b0154d5cde Fix querying fields present in both tables 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
3347020c6c Add support for filtering relations 2024-06-16 15:28:45 +01:00
freddiewanah
e0de6e1b89 refactor the test methods to avoid suboptimal asserts. 2024-04-08 21:39:25 +08:00
Lars Kruse
508d28f66b tests: move reusable test-related modules into the beets package
External Python packages interfacing beets may want to use an in-memory
beets library instance for testing beets-related code.
The `TestHelper` class is very helpful for this purpose.
Previously `TestHelper` was located in the `test/` directory.
Now it is part of `beets` itself (`beets.test.helper.TestHelper`) and
can be easily imported.
2024-01-15 19:40:57 +01:00
Serene-Arc
a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
Jesse Bannon
f72261e44f Add support for artists and albumartists multi-valued tags (#4743)
Adds the following fields with id3v2.4 multi-valued tag support to autotag:
    - artists, artists_sort, artists_credit
    - albumartists, albumartists_sort, albumartists_credit
    - mb_artistids, mb_albumartistids

MusicBrainz support to populate + write the above multi-valued tags by default. Can be toggled to use id3v2.3 or id3v2.4 tags via the existing beets configuration option `id3v23`.

Big thanks to @JOJ0, @OxygenCobalt, @arsaboo for testing + @sampsyo for the initial code review .
2023-09-09 09:46:26 +02:00