Commit Graph

32 Commits

Author SHA1 Message Date
Philipp Wolfer
4dffc55ef1 Merge pull request #1379 from phw/PICARD-1677-ignore-tags
PICARD-1677: Tags can be ignored for metadata comparisson
2019-11-29 17:02:15 +01:00
Philipp Wolfer
4f684d0a48 PICARD-1678: Fix Picard crashing on non-integer search scores
If the search scores returned by the server are not integer values Picard crashed during metadata comparisson.
2019-11-29 17:00:59 +01:00
Philipp Wolfer
c6fcf3f1a0 PICARD-1677: Allow ignoring tags for metadata comparisson
Files that only differ in the tags set in the ignore list will not show up as changed even if those tags have changed.
2019-11-29 15:21:10 +01:00
Philipp Wolfer
96ca9188ba PICARD-1406: Make setting data in Metadata consistently use strings
- All Metadata methods setting data (__setitem__, set, add, add_unique) will convert values to strings
- __setitem__ and set are equivalent
2019-11-12 07:55:54 +01:00
Philipp Wolfer
05ffd72884 tests: use assertIn and assertNotIn 2019-09-13 22:09:36 +02:00
Philipp Wolfer
cdaf812587 PICARD-1573: Metadata.apply_func() must handle tags getting removed 2019-08-14 18:59:55 +02:00
Philipp Wolfer
40f12e5eb2 Simplified metadata comparisson in tests 2019-06-24 14:59:22 +02:00
Philipp Wolfer
604e542d10 Check if images get copied in test for Metadata.update() 2019-06-23 11:39:38 +02:00
Philipp Wolfer
0c57969735 PICARD-1529: Allow copying metadata without images 2019-06-23 11:35:18 +02: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
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
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
Laurent Monin
2aec4a4185 Metadata.update(): fix a corner case leading to inconsistent data
```python
m = Metadata(tag1='a', tag2='b')
del m['tag1']
```

```
m store: {'tag2': ['b']}
m deleted: {'tag1'}
```

```python
m2 = Metadata(tag1='c', tag2='d')
del m2['tag2']
```

```
m2 store: {'tag2': ['b']}
m2 deleted: {'tag1'}
```

```python
m.update(m2)
```

```
m store: {'tag1': ['c']}
m deleted: {'tag1', 'tag2'} <---- this was incorrect, and untested case
```

This patch fixes it, and results to:

```
m store: {'tag1': ['c']}
m deleted: {'tag2'}
```
2019-03-20 10:42:50 +01:00
Laurent Monin
090c1e4eaf Reduce code redundancy in tests 2019-03-20 10:42:50 +01:00
Laurent Monin
4e977cfb2c Improve dict compatibility of Metadata.update() + minor fixes 2019-03-20 10:42:50 +01:00
Laurent Monin
503b5203f1 Metadata class: inherit from MutableMapping instead of dict 2019-03-20 10:42:49 +01:00
Philipp Wolfer
c8cd00fd7e PICARD-1412: Consider deleted tags as changed 2018-11-14 09:18:15 +01:00
Wieland Hoffmann
e624aa121c Make PicardTestCase the parent class of all tests
This brings the faketagger and, more importantly, settings reset to all of them.
2018-10-23 17:32:50 +02:00
Laurent Monin
16a3074be4 PEP8 fixes 2018-09-13 17:54:13 +02:00
Philipp Wolfer
97bd392844 PICARD-1112: Clear deleted tags after saving file 2018-09-07 13:18:19 +02:00
Philipp Wolfer
cc93a2a45f PICARD-1332: Deleted tags on tracks get applied to matched files 2018-09-05 08:33:19 +02:00
Laurent Monin
5329e3592a Clean up and sort imports using isort
Add a config for isort (https://github.com/timothycrosley/isort)
Run isort -rc . and make import style consistent across files
Add a note about `isort` in CONTRIBUTING.md
2018-08-22 08:51:25 +02:00
Wieland Hoffmann
c18ae092ba Fix length_score and add tests
In 2f8496e, 1.0 - ... turned into 0.0. Fix that.
2018-01-18 20:58:32 +01:00
Sophist
6474915c00 Remove unneeded imports, refactor code. 2017-04-27 12:26:08 +01:00
Sophist
1112ea432c Add unit testsfor Metadata object variables 2017-04-26 22:53:57 +01:00