Commit graph

163 commits

Author SHA1 Message Date
Š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
wisp3rwind
1ef6b90786 add missing syspath conversions (1/3, tests)
these are mostly in the tests, which didn't cause issues since the
affected directories usually have nice ASCII paths. For consistency, it
is nicer to always invoke syspath. That also avoids deprecation warnings
for the bytestring interfaces on Python <= 3.5. The bytestring
interfaces were undeprecated with PEP 529 in Python 3.6, such that we
didn't observe any actual failures.
2023-06-24 14:52:46 +02:00
Šarūnas Nejus
724b06a77d
Define SingletonQuery to perform filtering through SQL
This slightly speeds up the queries and there's a nice side-effect where
`singleton:1` and `singleton:0` now work fine!

This is ultimately building towards replacing as many python-only
queries with SQL equivalents.
2023-04-08 06:15:04 +01:00
wisp3rwind
e6fd038b0e tests: robustify path query / case_sensitive tests
- samefile exists on all platforms for recent python
- don't rely on monkey-patching os/os.path and on specifics on the
  implementation: as a result of doing so, the tests start failing in
  obscure ways as soon as the implementation (and its usage of
  os.path.exists and os.path.samefile) is changed
2023-02-12 16:16:43 +01:00
wisp3rwind
a6d74686d8 test: separate case_sensitive unit tests from PathQueryTest
- move tests for case_sensitive to test_util.py, since this is not
  really the concern of PathQueryTest
- removes part of the tests, since the tests that patch os.path.samefile
  and os.path.exists are super brittle since they test the
  implementation rather than the functionality of case_sensitive().
  This is a prepartory step for actually changing the implementation,
  which would otherwise break the tests in a confusing way...
2022-12-24 13:36:53 +01:00
Adrian Sampson
32ce44f589
One more test fix 2022-08-17 16:25:17 -07:00
Adrian Sampson
495c8accc0
Update exact query prefix tests 2022-08-17 16:11:16 -07:00
Šarūnas Nejus
72c5302004
Fix lints 2022-05-31 22:45:05 +01:00
Šarūnas Nejus
ba777dda50
Skip implicit paths tests for win32 2022-05-31 22:34:40 +01:00
Šarūnas Nejus
d68ed1adca
Make implicit path queries explicit and simplify their handling 2022-05-31 21:51:47 +01:00
Rob Crowell
2cab2d670a Fix bug in StringQuery.string_match 2022-01-25 16:24:04 -08:00
Rob Crowell
6457532274 Add query prefixes :~ and := 2022-01-24 19:19:48 -08:00
mousecloak
0132067a29
Fix @unittest.skipIf annotations to ignore only win32 2022-01-07 21:29:44 -08:00
Andrew Rogl
9106b41a50 Remove as many as possible sys.version tests 2021-08-27 10:24:27 +10:00
Andrew Rogl
ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl
1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Adrian Sampson
ea3a6e5fd7
Skip some more tests on Windows
We should actually fix these, I suppose!
2021-08-21 13:35:28 -04:00
FichteFoll
eda9930c59
Merge remote-tracking branch 'upstream/master' into pr/item-album-fallback 2020-07-27 19:32:44 +02:00
Adam Jakab
611659d03c removed value_match and repr tests 2020-03-16 10:16:29 +01:00
Adam Jakab
ac1a3851fa typo fix 2020-03-15 19:36:38 +01:00
Adam Jakab
ceb901fcca struggling with old python 2020-03-15 19:30:24 +01:00
Adam Jakab
935768d983 fixing repr tests 2020-03-15 19:19:09 +01:00
Adam Jakab
8e68b5ff2e cleaning up 2020-03-15 15:54:01 +01:00
Adam Jakab
532c6d7c82 better repr testing #2 2020-03-15 15:41:32 +01:00
Adam Jakab
3f2f125b09 better repr testing 2020-03-15 15:24:17 +01:00
Adam Jakab
d6538e5f0c removed value_match method - not reachable? 2020-03-15 14:57:02 +01:00
FichteFoll
72515448ad
Add fallback for item access to album's attributes
Allows queries (especially for pathspecs) based on an album's flexattrs
while operating on items.

Fixes #2797.
2019-06-05 02:38:46 +02:00
Adrian Sampson
2a9be17cf6 Fix some brittle query tests
These were written to incidentally depend on Nones; the behavior they're
actually testing doesn't really have anything to say about None-ness.
2017-06-20 15:56:33 -04:00
discopatrick
58417526cb Rename InvalidQueryArgumentTypeError to InvalidQueryArgumentValueError
The way we use `InvalidQueryArgumentTypeError` is more akin to a `ValueError` than a `TypeError`. For example, we try to parse a string as an int, float, or date, but the parsing fails - there was nothing wrong with the type of the variable (string), but its contents were not parseable into the type we wanted - there was a problem with the value of the string.
2017-04-22 18:07:30 +01:00
discopatrick
d466f8802c passes flake8 2017-04-14 14:45:51 +01:00
discopatrick
ff4c0abcf1 tests ‘added’ instead of ‘mtime’ , and uses a correct date format 2017-04-14 13:05:13 +01:00
discopatrick
a3251ef7c6 skips tests for now 2017-04-14 01:13:02 +01:00
Adrian Sampson
a88682e7bb Undo from _common import unittest indirection
This was a vestige from when we used to need the unittest2 library for pre-2.7
compatibility. Now that we require Python 2.7, we aren't using that library
and this indirection wasn't doing any good.
2016-11-26 18:46:44 -05:00
Johnny Robeson
24ae4bb056 encode path as utf-8 for is_path_query tests
is_path_query is not supposed to accept bytestrings
2016-07-02 01:24:25 -04:00
Adrian Sampson
736ad66518 Merge pull request #2066 from beetbox/use-six
Use the six package to handle py2/p3 compatibility
2016-06-25 18:09:56 -07:00
Johnny Robeson
34074b530b check changed text on py >3.5 in RegexpQuery test
See https://bugs.python.org/issue22364 for details
2016-06-24 19:09:29 -04:00