Commit graph

286 commits

Author SHA1 Message Date
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
Lars Kruse
7707e23456 tests: move reusable components from test.test_importer to test.helper
`ImportHelper` and `AutotagStub` are used in many tests.
Thus, they should reside in a module which is obviously used by multiple
tests.
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
Adrian Sampson
c15ccb16bf
Merge pull request #4900 from fracai/4326-scrub-no-rewrite
4326 scrub should not restore on import if "write" is disabled
2023-09-16 12:47:07 -04:00
Arno Hautala
5c34db565c must unload_plugins() during teardown after load_plugins() during setup 2023-09-12 20:09:59 -04:00
Arno Hautala
e91a56d180 fix tests 2023-09-11 12:03:25 -04:00
Arno Hautala
8defbe4093 scrub on import tests 2023-09-10 19:03:13 -04: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
9af9eb9b31 tests: make use of our custom filesystem assertions for conciseness
this replaces assertions of the form
    self.assertTrue(os.path.exists(syspath(path)))
by
    self.assertExists(path)
which includes the syspath conversion and is much easier to read.

Occurences where located using
    git grep -E 'assert(True|False).*(isdir|isfile|exist)'
2023-07-16 10:42:47 +02:00
Adrian Sampson
16a30f4d74
Merge pull request #4714 from TypicalFence/gh-654
resolve transl-tracklisting relations for pseudo releases
2023-06-26 14:40:28 -07: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
fence
dccc62443d fix tests 2023-06-19 20:13:16 +02:00
wisp3rwind
5de1d12610 tests: address some warnings
- some helper functions were incorrectly detected as being tests due to
  their name
- use of the deprecated assertEquals alias
2023-05-07 18:43:43 +02:00
J0J0 Todos
efc88193f9 Add test_reimported_album_not_preserves_flexattr
Checks if a reimported album flexible attribute "data_source" will be updated
correctly from the match being applied.
2023-04-11 07:11:20 +02:00
Adrian Sampson
1054b729d3
Merge branch 'master' into duplicate 2022-08-21 10:34:15 -07:00
Adrian Sampson
3c945cba0c
Change config key from "single" to "item"
For consistency with the rest of the terminology in the docs/config.
Also, correct the documentation (which previously only covered albums).
2022-08-21 10:31:45 -07:00
Adrian Sampson
7af40db050
Merge branch 'master' into formatted-modify 2022-08-20 16:37:52 -07:00
Adrian Sampson
c5e68f5643
Adapt to pycodestyle changes 2022-07-30 19:54:24 -04:00
Julien Cassette
7633465734 Add duplicate_keys feature for singletons 2022-01-22 22:36:47 +01:00
Julien Cassette
f50d250c4a Review duplicate_keys feature 2022-01-22 16:49:45 +01:00
Julien Cassette
6ce29a6b1b Allow to use flexible attributes in duplicate_keys 2022-01-22 15:00:18 +01:00
wisp3rwind
807f124ef8 really remove all six imports
apparently, pyupgrade didn't know how to handle these...
2022-01-20 00:26:01 +01:00
Duncan Overbruck
819ba735bd
allow templates/formatting of set_fields on import 2021-10-27 00:28:23 +02: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
Bert Besser
8dc960b1f6 fix: formatting 2021-05-14 10:19:59 +02:00
Bert Besser
e98f78e29b fix: transactions and stricter tests 2021-05-13 15:09:55 +02:00
bertbesser
a25a2a6cbb
Merge branch 'master' into set-fields-persist-to-tracks 2021-05-13 07:38:26 +02:00
Andrew Rogl
533559136e Add 7z file support #3906 2021-05-07 22:04:46 +10:00
Bert Besser
9cbbc35a95 persist set_fields to media files 2021-05-06 19:55:12 +02:00
x1ppy
19d6dfc8f3 Support extra tags for MusicBrainz queries 2020-03-20 14:13:40 -04:00
Carl Suster
10d41a1cbb tests: avoid non-test classes named Test*
When using pytest's test collector, any class with a name starting with
Test is collected. If it notices that the class has an `__init__` member
then it skips it with a warning since it's probably a false positive.
This isn't a big deal, but we can avoid warnings like this:

    test/test_ui_importer.py:33
      beets/test/test_ui_importer.py:33: PytestCollectionWarning: cannot collect test class 'TestTerminalImportSession' because it has a __init__ constructor
        class TestTerminalImportSession(TerminalImportSession):

simply by renaming TestX to XFixture.
2019-06-02 16:35:37 +10:00
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Zsin Skri
77242d6b2b add test: from_scratch only removes writeable
Tests for commit ba8fcdfd from_scratch import: only remove writable fields.
2018-07-01 20:23:41 +02:00
Jérémie Detrey
f74899ab9a Fix errors due to missing track['id'] in unit tests. 2018-04-30 18:26:06 +02:00
tummychow
e848adab04 Implement from_scratch option
Fixes #934, and also helps with #1173.
2017-12-07 14:46:40 -05:00
Meet Udeshi
70f0bc5b6c Implement album merging for duplicates
Fixes #112
2017-11-01 02:00:48 +05:30
Bart Kleijngeld
762f9ca054 revised to fix flake8 warnings 2017-06-13 14:33:08 +02:00
Bart Kleijngeld
c64878179e finished tests for set_fields on importer 2017-06-01 11:57:24 +02:00
Jacob Gillespie
1fd22604fb Fix linter issues 2017-02-19 17:33:26 -06:00
Jacob Gillespie
b4efecb709 Add option to hardlink when importing 2017-02-19 15:56:13 -06:00
Mike Cameron
3f67a27989 Fixed failing test because mocked data was missing property
umber.
2017-01-10 18:21:28 -05: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
7a2bdf502f s/utf8/utf-8/ in all encoding/decoding contexts
This matches up with the python documentation.
2016-09-06 23:10:24 -04:00
Jesse Weinstein
92d008b155 Fix overlength lines 2016-07-24 12:11:35 -07:00
Jesse Weinstein
e5a723b899 Switch test_importer over to use @patch 2016-07-22 23:35:33 -07:00
Johnny Robeson
f9dfd34602 use py3_path for archive (ZipFile, etc) filenames
ZipFile and RarFile both only accept string filenames on py3, not
bytestrings.
2016-07-10 01:53:24 -04:00
Johnny Robeson
53d1dc905f add a missing bytestring_path in importer test 2016-07-05 01:33:43 -04:00
Johnny Robeson
02680eba59 bytestringify a few more paths in test_importer 2016-07-02 01:52:00 -04:00
Johnny Robeson
5f4678e3e8 use StringIO from six 2016-06-23 04:40:18 -04:00
Adrian Sampson
5909c9ee89 Fix #2051: don't try to sort None
I found the point in the test harnesses where None was introduced as a value
for `TrackInfo.index`. Just using zero works fine.
2016-06-21 15:02:05 -07:00
Johnny Robeson
ffa46a185c bytestring normalization
Make sure many/most strings that touch the filesystem are
converted explicitly to bytestrings rather than implictly.
2016-06-13 05:39:09 -04:00
Adrian Sampson
9204604a7c Fix path types in albums_in_dir tests 2016-06-10 12:49:08 -07:00
Johnny Robeson
daac41668e use util.displayable_path in more tests 2016-06-10 03:54:39 -04:00
Johnny Robeson
a274b4e737 read and write the pickled statefile as binary
Pickle files should be treated as binary files
2016-06-10 02:02:28 -04:00
Adrian Sampson
0f8fc33952 Fix inverted assertion sense
I broke this in 2fefd24 by using the wrong assertion.
2016-06-09 10:23:24 -07:00
Adrian Sampson
2fefd2471a Use our higher-level assertions for files 2016-06-09 09:39:44 -07:00
Adrian Sampson
8359b9e90f Tests: path equality assertion 2016-06-06 11:30:38 -07:00
Adrian Sampson
71b9fd785c Revert "Do __name__ comparison with bytes and not unicode"
This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
2016-05-29 19:19:59 -07:00
Jack Wilsdon
b1c58e99ec Update code to match pep8 naming standards 2016-04-27 20:15:10 +01:00
Adrian Sampson
e54c7eec3d Standardize __future__ imports without parentheses
Since the list is short enough now, we don't need parentheses for the line
wrap. This is a little less ugly.
2016-02-28 15:03:51 -08:00
Peter Kessen
df7241ecce Removed unicode_literals from test_importer 2016-02-28 13:37:13 +01:00
Diego Moreda
79d84c0e4f Style and doc fixes for MB_id importer argument
* Rename the importer argument and related variables to make it more
generic, as the feature should be independent of the backend used and
not restricted to MusicBrainz.
* Update documentation and docstrings accordingly.
* Add changelog entry.
2016-01-22 16:31:00 +01:00
Diego Moreda
4eedd2bd8d Store user-supplied MB ids on the Tasks
* Store the user-supplied MusicBrainz IDs (via the "--musicbrainzid"
importer argument) on ImporTask.task.musicbrainz_ids during the
lookup_candidates() pipeline stage.
* Update test cases to reflect the changes.
2016-01-21 20:33:54 +01:00
Diego Moreda
39cf4651b8 Fix singleton candidate ordering when using MB id
* Fix an issue that caused the candidates for a singleton not to be
returned ordered by distance from autotag.match.tag_item(), when
searching multiple MusicBrainz ids (ie. several "--musicbrainzid"
arguments). The candidates are now explicitely reordered before being
returned and before the recommendation is computed.
* Fix test_importer.mocked_get_recording_by_id so that the artist is
nested properly (and as a result, taken into account into the distance
calculations).
2016-01-20 20:22:48 +01:00
Diego Moreda
4e5ddac949 Avoid querying MB during ImportMusicBrainzIdTest
* Replace the entities used on ImportMusicBrainzIdTest mocking the calls to
musicbrainzngs.get_release_by_id and musicbrainzngs.get_recording_by_id instead
of querying MusicBrainz.
* Other cleanup and docstring fixes.
2016-01-20 17:03:16 +01:00
Diego Moreda
c12e974852 Merge remote-tracking branch 'upstream/master' into mbid 2016-01-19 21:58:10 +01:00
Diego Moreda
865be11ba1 Add tests for importer musicbrainz id argument
* Add tests for the "--musicbrainzid" argument (one/several ids for matching
an album/singleton; direct test on task.lookup_candidates() for
album/singleton).
2016-01-19 21:51:41 +01:00
Jesse Weinstein
72ce9ea3eb use underscore in name for pep-8s sake 2016-01-12 22:14:12 -08:00
Jesse Weinstein
d93f723263 Convert SKIP_SLOW_TESTS to its own decorator 2016-01-12 21:53:52 -08:00
Jesse Weinstein
760298b8e4 Mark slow tests to be skipped if SKIP_SLOW_TESTS env var is defined
Saves over 100 seconds.
2016-01-10 23:18:47 -08:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00:00
Peter Kessen
3eb8008b11 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files with correct license in header
2015-11-19 18:41:01 +01:00
reiv
314dd0e6bc Update re-import test to leave no orphaned art
Make sure that when an album is re-imported and its files are
moved, the artwork isn't left behind in the old folder.
2015-11-03 23:10:01 +01:00
reiv
21f926fb89 Add test for #314
Ensure that album art is preserved when an album is re-imported.
2015-11-03 22:38:13 +01:00
Adrian Sampson
ba87ea1f30 Skip symlink tests on Windows
... where there is no symlinking.
2015-04-23 17:43:15 -07:00
Bruno Cauet
5e26d483a8 Replace deprecated assertEquals with assertEqual. 2015-04-01 10:48:03 +02:00
Tom Jaspers
1555d3fe17 Importer metadata source is saved as flex attr
Saving a file "as is" keeps the data_source attribute unset
2015-02-15 17:46:00 +01:00
Tom Jaspers
20ae26dd77 Importer metadata source is set as a field: tests
See #1311
2015-02-11 10:14:56 +01:00
Adrian Sampson
3f0dbb876d Tests for #1285: normalize Unicode filenames 2015-01-31 11:54:32 -08:00
Adrian Sampson
9de9d2497f Unicode tests for #1285 2015-01-31 11:29:32 -08:00
Adrian Sampson
614fbf20ca Tests for #1285: parameterize tests
Also remove an errant `print` and use `rb''` literals for regexes.
2015-01-31 11:24:27 -08:00
Bruno Cauet
e99adddb11 Importer: byte strings for multi-disc directories
Make regexes from raw byte strings and not unicode.
Update the tests.

Fix #1285
2015-01-31 15:40:49 +01:00
Bruno Cauet
9c41c39913 Do __name__ comparison with bytes and not unicode 2015-01-20 12:03:57 +01:00
Bruno Cauet
2dab8e5fd6 Import unicode_literals in beets package 2015-01-19 21:41:33 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
2902cda036 tests: use absolute imports everywhere 2015-01-19 12:25:15 +01:00
Adrian Sampson
dc5a79e35c New import_task_created event
Part of #1186.
2015-01-18 15:37:48 -08:00
Bruno Cauet
621ea60af4 Improve importer log unicode-handling test
Send unicode instead of utf8-encoded string and check that the
non-ASCII char is correctly handled.

Bonus: use unittest.TestCase.assertIn(A, B) instead of "assert A in B".
2015-01-12 22:20:58 +01:00
Bruno Cauet
8418fb6083 Use a standard logger for the import log
The import log now relies on a standard logger, named 'beets.importer'
and configured upon initialization of the import session.
2015-01-12 21:47:44 +01:00
Frederik “Freso” S. Olesen
4b1f0cbf48 Happy 2015. ;)
See 7a410f636b

Command used:

    git grep -l 'Copyright 201'|xargs sed -i -E 's/Copyright 201./Copyright 2015/'`
2015-01-08 21:37:09 +01:00
Malte Ried
bee0a5b9fe Album tracks are prepended by two spaces to indent them a bit. 2014-12-31 11:38:03 +01:00
Malte Ried
cc82e1cb43 Made the detailed output the default behaviour. 2014-12-31 11:30:46 +01:00
Malte Ried
023c13d292 Updated the test code to ignore the "Sending event" log messages. 2014-12-29 13:22:28 +01:00
Malte Ried
5123a41258 Added a flag --detailed to get a more detailed output of the --pretend option. 2014-12-29 12:54:16 +01:00
Malte Ried
5f67f3ae51 The last commit broke the tests. Repaired... 2014-12-21 21:52:09 +01:00
Malte Ried
440fe9a2ea Reduced the count of accesses of the pretend config option. Now it's only one place where it is read.
Changed the output to use the log system rather than print_.
2014-12-21 21:37:44 +01:00
Malte Ried
2db346388a Added option --pretend to only print the filenames of files to import without importing them 2014-12-21 15:56:56 +01:00
Thomas Scholtes
eb8ccef8e6 Fix py26 string format 2014-12-01 13:05:29 +01:00
Thomas Scholtes
75c6af6329 Warn user when no files are imported from a directory
Fixes #1116.
2014-12-01 12:31:49 +01:00
David
5f1f6bbd04 Remove function from RmTempTest 2014-11-16 21:53:33 -05:00