Commit Graph

437 Commits

Author SHA1 Message Date
Philipp Wolfer
dc0ec84401 isort: Consistently use two blank lines after import 2019-04-04 08:35:23 +02:00
Philipp Wolfer
dd4da2aa47 Updated isort config to put test imports in separate section 2019-04-04 08:32:22 +02:00
Philipp Wolfer
05fc98c64a Run isort over all files 2019-04-03 21:19:12 +02:00
Laurent Monin
fb6807636d Add tests for config upgrade functions 2019-04-03 12:22:53 +02:00
Laurent Monin
a63cc6bdd1 Rework config and add tests for it
- get rid of useless ConfigSection.__config
- use name instead of full key (as section name is fixed)
- add support for qt type
- remove _convert_to_bool(), unneeded with qt type support
2019-04-03 09:46:52 +02:00
Laurent Monin
0f1ca5379a Move to DEFAULT_FILE_NAMING_FORMAT to picard.const 2019-04-02 14:06:49 +02:00
Philipp Wolfer
7cf3945272 Removed unused imports 2019-03-29 10:55:28 +01:00
Philipp Wolfer
e41c683c0f Merge pull request #1160 from phw/fix-config-loading
Fix loading BoolOption from config
2019-03-29 09:10:20 +00:00
Philipp Wolfer
63cb114080 Always run tagger.run_cleanup for PicardTestCase 2019-03-29 08:59:14 +00:00
Philipp Wolfer
d0563fa5c4 Extended option test cases 2019-03-29 09:30:09 +01:00
Philipp Wolfer
0405f7acb5 Added tests for config options 2019-03-29 09:06:54 +01:00
Philipp Wolfer
ea9ad532b2 PICARD-1497: Mark invalid Apev2 keys as unsupported tags 2019-03-28 22:52:59 +01:00
Philipp Wolfer
dd12220e1e PICARD-1497: Mark invalid Vorbis keys as unsupported tags 2019-03-28 22:52:59 +01:00
Laurent Monin
0724e8fb26 metadata.delete('tag') -> del metadata['tag'] 2019-03-28 13:39:51 +00:00
Philipp Wolfer
10f896d327 Formats test code cleanup
Addressed review comments
2019-03-28 14:18:14 +01:00
Philipp Wolfer
12548bb638 Added tests for ASF utility functions 2019-03-28 11:45:42 +01:00
Philipp Wolfer
7c7ad564d5 Added tests for ID3 utility functions 2019-03-28 11:45:42 +01:00
Philipp Wolfer
09fe255891 Renamed base test case classes for consistency 2019-03-28 11:45:42 +01:00
Philipp Wolfer
a268b13ceb Refactored cover art file tests into format specific test files 2019-03-28 11:45:42 +01:00
Philipp Wolfer
a1313bef84 PEP8 fixes 2019-03-28 11:45:42 +01:00
Philipp Wolfer
3b3980adb0 Added tests for technical file info tags 2019-03-28 11:45:42 +01:00
Philipp Wolfer
8fdfcf1ffe Restructure format tests into separate files 2019-03-28 11:10:06 +01:00
Philipp Wolfer
ab1adf15cb Add common tests for Vorbis formats 2019-03-27 15:05:47 +01:00
Philipp Wolfer
cf9528bd86 PICARD-1492: Added tests and docs for vorbis.sanitize_key 2019-03-26 16:06:08 +01:00
Philipp Wolfer
2d98026c22 PICARD-1492: Fix saving Vorbis ratings with invalid chars in user e-mail 2019-03-26 09:24:56 +01:00
Philipp Wolfer
3a2cfc3a89 Fix ASFFile._save modifying passed metadata 2019-03-26 07:32:59 +00:00
Philipp Wolfer
601df7b158 Simpified initializing Metadata() in formats tests 2019-03-26 07:32:59 +00:00
Laurent Monin
c80ae1344b Name countries-related tests, classes and variables consistently 2019-03-25 14:40:52 +01:00
Laurent Monin
a458bbe2ff country_list_from_node() -> countries_from_node() 2019-03-25 14:38:51 +01:00
Laurent Monin
5ae92454f4 Add a test for release without events vs countries 2019-03-25 14:36:56 +01:00
Laurent Monin
4983631f70 Merge pull request #1142 from zas/coverimage_metadata_cleanup
CoverArtImage/ImageList/Metadata cleanup
2019-03-24 14:33:50 +01:00
Laurent Monin
b33e59428f Clean up various matching iterations, unify a bit
- use generators for candidates
- introduce picard.util.find_best_match() and sort_by_similarity() with tests
- partially revert change that removed sorted(), it was actually faster and cleaner
- use namedtuples to get rid of numeric indexes
- when no match, output max similarity, threshold and number of candidates to debug log
- make code easier to understand, using long names and namedtuple attributes, and simpler workflow
- use repr(best_match) for debug, as it provides all the needed info
- set values explicitly using namedtuple kw parameters
- use same prefix for namedtuples names, it eases searching through code

Typical debug output looks like:
```
D: 13:16:41,806 cluster._lookup_finished:223: BestMatch(similarity=0.79, result=SimMatchRelease(similarity=0.79, release={'id': '36b8f767-c4c0-4ba1-becd-f40a452303d5', 'score': 79, 'count': 1, 'title': 'Purple', 'status': 'Official', 'packaging': 'Jewel Case', 'text-representation': {'language': 'eng', 'script': 'Latn'}, 'artist-credit': [{'artist': {'id': '8c32bb01-58a3-453b-8050-8c0620edb0e5', 'name': 'Stone Temple Pilots', 'sort-name': 'Stone Temple Pilots'}}], 'release-group': {'id': '01d45519-54a6-3427-b0dc-222203fa5d57', 'type-id': 'f529b476-6e62-324f-b0aa-1f3e33d313fc', 'title': 'Purple', 'primary-type': 'Album'}, 'date': '1995-08-25', 'country': 'US', 'release-events': [{'date': '1995-08-25', 'area': {'id': '489ce91b-6658-3307-9877-795b68554c98', 'name': 'United States', 'sort-name': 'United States', 'iso-3166-1-codes': ['US']}}], 'track-count': 11, 'media': [{'format': 'CD', 'disc-count': 10, 'track-count': 11}]}), num_results=25) < threshold=0.800000
```
2019-03-23 16:29:44 +01:00
Laurent Monin
7e3c9673c8 Add test for Metadata.apply_func() with preserved tags 2019-03-22 11:04:44 +01:00
Laurent Monin
b81947e22d Add test for Metadata.strip_whitespace() 2019-03-22 10:54:31 +01:00
Laurent Monin
99896bff8b Add tests for ImageList copy()/clear()/del
Note: clear() is apparently inherited, i read docs saying otherwise, so i add a test for it to be sure
2019-03-22 10:32:32 +01:00
Laurent Monin
3a44ec41e2 Disable pylint warning about ImageList.insert() 2019-03-22 10:32:32 +01:00
Laurent Monin
9340c6c2ec Drop Metadata.set_front_image(), replace with ImageList.strip_front_images()
- only used in ui/coverartbox.py and not directly linked to metadata
- add tests
-
2019-03-22 10:32:31 +01:00
Laurent Monin
78c9890e21 Drop Metadata.append_image(), use Metadata.images.append() instead 2019-03-22 10:32:31 +01:00
Laurent Monin
6bf103bf34 Drop useless Metadata.remove_image() 2019-03-22 10:32:31 +01:00
Laurent Monin
0b837ebe8d Move Metadata.images_to_be_saved_to_tags() to ImageList.to_be_saved_to_tags()
- make it a generator
- drop @property, it's a function, no point in hiding it
- add tests
2019-03-22 10:32:31 +01:00
Laurent Monin
eb73ea6bc4 Replace Metadata.get_single_front_image() with ImageList.get_front_image()
- it makes much more sense, Metadata.images is an ImageList
- minimal changes required
- add tests for it
2019-03-22 10:32:31 +01:00
Laurent Monin
d60afe35d7 ImageList(): fix untestable class, since it requires gettext...
- image.types_as_string() was called from get_image_type() without translate=False
- dependency wasn't satisfied, so impossible to test as is
- make tests depending on languages isn't a good idea anyway
- use new CoverArtImage.normalized_types() instead
- simplify code
- add tests for ImageList.append() and ImageList.__eq__()
2019-03-22 10:32:31 +01:00
Laurent Monin
9d7b8dc995 CoverArtImage.__init__(): add parameters to override supported types
It's convenient for testing
2019-03-22 10:32:31 +01:00
Laurent Monin
bc11a330ab Introduce SettingsOverride class to fix this more elegantly
- basically it returns config.setting[key] when key isn't in the internal dict
- it protects config.setting from any write, since __setitem__ only write to self._dict
- del settings['xxx'] will remove 'xxx' from internal dict, but still allow access to config.setting
- it can be used for tests
- minimal implementation based on MutableMapping
- add tests for it
2019-03-22 10:29:57 +01:00
Laurent Monin
b58c353259 Metadata.__setitem__(): accept any iterable as values
https://github.com/metabrainz/picard/pull/1137#discussion_r266974994
2019-03-21 11:53:39 +01:00
Laurent Monin
b5cc54e255 Make Metadata.__setitem__() consistent with Metadata.add() regarding 0 values
m['tag'] = 0 wasn't doing the same thing as m.add('tag', 0), because the test in __setitem__()
was different: if value vs if value or value == 0
So modify it to make behavior much more consistent.

m['tag'] = 0 or m.add('tag', 0) actually set tag to ['0']
m.add('tag', '') does nothing
m['tag'] = '' explicitly delete the tag (removing it from store, adding it to deleted tags)
m = Metadata(tag='') doesn't create an entry 'tag' (at all)
m = Metadata(tag=0) creates a tag, with internal value ['0']

This way, one can rewrite:

self.metadata = Metadata()
self.metadata['album'] = name
self.metadata['albumartist'] = artist
self.metadata['totaltracks'] = 0

to:
self.metadata = Metadata(album=name, albumartist=artist, totaltracks=0)

Without this patch, totaltracks wasn't set at all.
2019-03-21 11:38:58 +01:00
Laurent Monin
99604ac01f Test and annotate the case of del with unknown keys 2019-03-20 21:17:06 +01:00
Laurent Monin
f6e3aedf7a Raises TypeError if Metadata.update() is called without argument
This is more consistent with dict.update() behavior (and shouldn't happen anyway).
2019-03-20 11:03:56 +01:00
Laurent Monin
39b069adae Test Metadata.len() with images 2019-03-20 10:42:50 +01:00
Laurent Monin
1a1e250489 Add tests for Metadata with images 2019-03-20 10:42:50 +01:00