mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-09 10:03:59 +00:00
fixing test cases by making settings to file loading optional
This commit is contained in:
@@ -241,7 +241,7 @@ class Cluster(QtCore.QObject, Item):
|
||||
|
||||
|
||||
class UnmatchedFiles(Cluster):
|
||||
"""Special cluster for 'Unmatched Files'."""
|
||||
"""Special cluster for 'Unmatched Files' which have no PUID and have not been clustered."""
|
||||
|
||||
def __init__(self):
|
||||
super(UnmatchedFiles, self).__init__(_(u"Unmatched Files"), special=True)
|
||||
@@ -387,7 +387,7 @@ class ClusterEngine(object):
|
||||
|
||||
def cluster(self, threshold):
|
||||
|
||||
# keep the matches sorted in a heap
|
||||
# Keep the matches sorted in a heap
|
||||
heap = []
|
||||
|
||||
for y in xrange(self.clusterDict.getSize()):
|
||||
|
||||
@@ -35,7 +35,7 @@ def supported_formats():
|
||||
return formats
|
||||
|
||||
def open(filename):
|
||||
"""Open the specified file and return a File instance, or None."""
|
||||
"""Open the specified file and return a File instance with the appropriate format handler, or None."""
|
||||
i = filename.rfind(".")
|
||||
if i < 0:
|
||||
return None
|
||||
|
||||
@@ -79,14 +79,14 @@ class APEv2File(File):
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
"""Save metadata to the file."""
|
||||
self.log.debug("Saving file %r", filename)
|
||||
try:
|
||||
tags = mutagen.apev2.APEv2(encode_filename(filename))
|
||||
except mutagen.apev2.APENoHeaderError:
|
||||
tags = mutagen.apev2.APEv2()
|
||||
if settings["clear_existing_tags"]:
|
||||
if settings.has_key("clear_existing_tags") and settings["clear_existing_tags"]:
|
||||
tags.clear()
|
||||
temp = {}
|
||||
for name, value in metadata.items():
|
||||
|
||||
@@ -87,7 +87,7 @@ class ASFFile(File):
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
self.log.debug("Saving file %r", filename)
|
||||
file = ASF(encode_filename(filename))
|
||||
for name, values in metadata.rawitems():
|
||||
|
||||
@@ -183,7 +183,7 @@ class ID3File(File):
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
"""Save metadata to the file."""
|
||||
self.log.debug("Saving file %r", filename)
|
||||
try:
|
||||
@@ -191,15 +191,17 @@ class ID3File(File):
|
||||
except mutagen.id3.ID3NoHeaderError:
|
||||
tags = compatid3.CompatID3()
|
||||
|
||||
if settings['clear_existing_tags']:
|
||||
if settings.has_key("clear_existing_tags") and settings['clear_existing_tags']:
|
||||
tags.clear()
|
||||
if settings['remove_images_from_tags']:
|
||||
if settings.has_key("remove_images_from_tags") and settings['remove_images_from_tags']:
|
||||
tags.delall('APIC')
|
||||
|
||||
if settings['write_id3v1']:
|
||||
if settings.has_key("write_id3v1") and settings['write_id3v1']:
|
||||
v1 = 2
|
||||
else:
|
||||
v1 = 0
|
||||
if not settings.has_key("id3v2_encoding"):
|
||||
settings["id3v2_encoding"] = "utf-8"
|
||||
encoding = {'utf-8': 3, 'utf-16': 1}.get(settings['id3v2_encoding'], 0)
|
||||
|
||||
if 'tracknumber' in metadata:
|
||||
@@ -216,7 +218,7 @@ class ID3File(File):
|
||||
text = metadata['discnumber']
|
||||
tags.add(id3.TPOS(encoding=0, text=text))
|
||||
|
||||
if settings['save_images_to_tags']:
|
||||
if settings.has_key("save_images_to_tags") and settings['save_images_to_tags']:
|
||||
for mime, data in metadata.images:
|
||||
tags.add(id3.APIC(encoding=0, mime=mime, type=3, desc='', data=data))
|
||||
|
||||
@@ -267,7 +269,7 @@ class ID3File(File):
|
||||
if tipl.people:
|
||||
tags.add(tipl)
|
||||
|
||||
if settings['write_id3v23']:
|
||||
if settings.has_key("write_id3v23") and settings['write_id3v23']:
|
||||
tags.update_to_v23()
|
||||
tags.save(encode_filename(filename), v2=3, v1=v1)
|
||||
else:
|
||||
@@ -277,7 +279,7 @@ class ID3File(File):
|
||||
tags.update_to_v24()
|
||||
tags.save(encode_filename(filename), v2=4, v1=v1)
|
||||
|
||||
if self._IsMP3 and settings["remove_ape_from_mp3"]:
|
||||
if self._IsMP3 and settings.has_key("remove_ape_from_mp3") and settings["remove_ape_from_mp3"]:
|
||||
try: mutagen.apev2.delete(encode_filename(filename))
|
||||
except: pass
|
||||
|
||||
|
||||
@@ -117,11 +117,11 @@ class MP4File(File):
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
self.log.debug("Saving file %r", filename)
|
||||
file = MP4(encode_filename(self.filename))
|
||||
|
||||
if settings["clear_existing_tags"]:
|
||||
|
||||
if settings.has_key("clear_existing_tags") and settings["clear_existing_tags"]:
|
||||
file.tags.clear()
|
||||
|
||||
for name, values in metadata.rawitems():
|
||||
|
||||
@@ -51,13 +51,13 @@ class VCommentFile(File):
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
"""Save metadata to the file."""
|
||||
self.log.debug("Saving file %r", filename)
|
||||
file = self._File(encode_filename(filename))
|
||||
if file.tags is None:
|
||||
file.add_tags()
|
||||
if settings["clear_existing_tags"]:
|
||||
if settings.has_key("clear_existing_tags") and settings["clear_existing_tags"]:
|
||||
file.tags.clear()
|
||||
tags = {}
|
||||
for name, value in metadata.items():
|
||||
@@ -77,7 +77,7 @@ class VCommentFile(File):
|
||||
tags.setdefault(name.upper().encode('utf-8'), []).append(value)
|
||||
file.tags.update(tags)
|
||||
kwargs = {}
|
||||
if self._File == mutagen.flac.FLAC and settings["remove_id3_from_flac"]:
|
||||
if self._File == mutagen.flac.FLAC and settings.has_key("remove_id3_from_flac") and settings["remove_id3_from_flac"]:
|
||||
kwargs["deleteid3"] = True
|
||||
try:
|
||||
file.save(**kwargs)
|
||||
|
||||
@@ -37,6 +37,6 @@ class WAVFile(File):
|
||||
metadata['~format'] = 'Microsoft WAVE'
|
||||
return metadata
|
||||
|
||||
def _save(self, filename, metadata, settings):
|
||||
def _save(self, filename, metadata, settings = {}):
|
||||
self.log.debug("Saving file %r", filename)
|
||||
pass
|
||||
|
||||
@@ -37,6 +37,7 @@ _replace_words = {
|
||||
}
|
||||
|
||||
def normalize(orig_string):
|
||||
"""Strips non-alphanumeric characters from a string unless doing so would make it blank."""
|
||||
string = strip_non_alnum(orig_string.lower()).strip()
|
||||
if not string:
|
||||
string = orig_string
|
||||
@@ -46,9 +47,7 @@ def normalize(orig_string):
|
||||
return string
|
||||
|
||||
def similarity(a1, b1):
|
||||
"""Calculates similarity of single words."""
|
||||
# return astrcmp(a1, b1)
|
||||
"""Calculates "smart" similarity of strings ``a`` and ``b``."""
|
||||
"""Calculates similarity of single words as a function of their edit distance."""
|
||||
a2 = normalize(a1)
|
||||
if a2:
|
||||
b2 = normalize(b1)
|
||||
|
||||
@@ -58,7 +58,9 @@ inline T max(T a, T b)
|
||||
}
|
||||
|
||||
/***
|
||||
* Compute Levenshtein distance
|
||||
* Compute Levenshtein distance. Levenshtein distance, also known as
|
||||
* "edit distance," is a measure of the cost to transform one string
|
||||
* into another.
|
||||
***/
|
||||
|
||||
#define MATRIX(a, b) matrix[(b) * (len1 + 1) + (a)]
|
||||
|
||||
Binary file not shown.
@@ -2,11 +2,20 @@ import os.path
|
||||
import unittest
|
||||
import shutil
|
||||
from tempfile import mkstemp
|
||||
from picard import log
|
||||
from picard.metadata import Metadata
|
||||
import picard.formats
|
||||
from PyQt4 import QtCore
|
||||
|
||||
|
||||
class FakeTagger():
|
||||
def __init__(self):
|
||||
if "PICARD_DEBUG" in os.environ:
|
||||
self.log = log.DebugLog()
|
||||
else:
|
||||
self.log = log.Log()
|
||||
QtCore.QObject.log = self.log
|
||||
|
||||
def emit(self, *args):
|
||||
pass
|
||||
|
||||
@@ -48,244 +57,245 @@ class FormatsTest(unittest.TestCase):
|
||||
def test_simple_tags(self):
|
||||
if not self.original:
|
||||
return
|
||||
for i in self.tags:
|
||||
if len(i) == 3:
|
||||
n, v, e = i
|
||||
else:
|
||||
n, v = i
|
||||
e = v
|
||||
f = picard.formats.open(self.filename)
|
||||
f._load()
|
||||
f.metadata[n] = v
|
||||
f.save()
|
||||
f = picard.formats.open(self.filename)
|
||||
f._load()
|
||||
self.assertEqual(f.metadata.getall(n), e, '%s: %r != %r' % (n, f.metadata.getall(n), e))
|
||||
|
||||
f = picard.formats.open(self.filename)
|
||||
# The loading process is very tightly coupled to the threading
|
||||
# library and loading without instantiating a thread pool
|
||||
# unless internal functions are used
|
||||
loaded_metadata = f._load(self.filename)
|
||||
f._copy_metadata(loaded_metadata)
|
||||
metadata = Metadata()
|
||||
for (key, value) in self.tags.iteritems():
|
||||
metadata[key] = value
|
||||
f._save(self.filename, metadata)
|
||||
f = picard.formats.open(self.filename)
|
||||
loaded_metadata = f._load(self.filename)
|
||||
f._copy_metadata(loaded_metadata)
|
||||
for (key, value) in self.tags.iteritems():
|
||||
self.assertEqual(f.metadata[key], value, '%s: %r != %r' % (key, f.metadata[key], value))
|
||||
|
||||
class FLACTest(FormatsTest):
|
||||
original = os.path.join('test', 'data', 'test.flac')
|
||||
tags = [
|
||||
('album', ['Foo', 'Bar']),
|
||||
('album', ['1']),
|
||||
('title', ['Foo']),
|
||||
('artist', ['Foo']),
|
||||
('albumartist', ['Foo']),
|
||||
('date', ['2004-00-00'], ['2004']),
|
||||
('artist', ['Foo']),
|
||||
('composer', ['Foo']),
|
||||
('lyricist', ['Foo']),
|
||||
('conductor', ['Foo']),
|
||||
('performer:guest vocal', ['Foo']),
|
||||
('remixer', ['Foo']),
|
||||
('engineer', ['Foo']),
|
||||
('producer', ['Foo']),
|
||||
('grouping', ['Foo']),
|
||||
('subtitle', ['Foo']),
|
||||
('discsubtitle', ['Foo']),
|
||||
('compilation', ['1']),
|
||||
('comment', ['Foo']),
|
||||
('genre', ['Foo']),
|
||||
('bpm', ['Foo']),
|
||||
('mood', ['Foo']),
|
||||
('isrc', ['Foo']),
|
||||
('copyright', ['Foo']),
|
||||
('lyrics', ['Foo']),
|
||||
('media', ['Foo']),
|
||||
('label', ['Foo']),
|
||||
('catalognumber', ['Foo']),
|
||||
('barcode', ['Foo']),
|
||||
('encodedby', ['Foo']),
|
||||
('albumsort', ['Foo']),
|
||||
('albumartistsort', ['Foo']),
|
||||
('artistsort', ['Foo']),
|
||||
('titlesort', ['Foo']),
|
||||
('musicbrainz_trackid', ['Foo']),
|
||||
('musicbrainz_albumid', ['Foo']),
|
||||
('musicbrainz_artistid', ['Foo']),
|
||||
('musicbrainz_albumartistid', ['Foo']),
|
||||
('musicbrainz_trmid', ['Foo']),
|
||||
('musicbrainz_discid', ['Foo']),
|
||||
('musicip_puid', ['Foo']),
|
||||
('releasestatus', ['Foo']),
|
||||
('releasetype', ['Foo']),
|
||||
]
|
||||
tags = {
|
||||
'album' : 'Foo Bar',
|
||||
'album' : '1',
|
||||
'title' : 'Foo',
|
||||
'artist' : 'Foo',
|
||||
'albumartist' : 'Foo',
|
||||
'date' : '2004',
|
||||
'artist' : 'Foo',
|
||||
'composer' : 'Foo',
|
||||
'lyricist' : 'Foo',
|
||||
'conductor' : 'Foo',
|
||||
'performer:guest vocal' : 'Foo',
|
||||
'remixer' : 'Foo',
|
||||
'engineer' : 'Foo',
|
||||
'producer' : 'Foo',
|
||||
'grouping' : 'Foo',
|
||||
'subtitle' : 'Foo',
|
||||
'discsubtitle' : 'Foo',
|
||||
'compilation' : '1',
|
||||
'comment' : 'Foo',
|
||||
'genre' : 'Foo',
|
||||
'bpm' : 'Foo',
|
||||
'mood' : 'Foo',
|
||||
'isrc' : 'Foo',
|
||||
'copyright' : 'Foo',
|
||||
'lyrics' : 'Foo',
|
||||
'media' : 'Foo',
|
||||
'label' : 'Foo',
|
||||
'catalognumber' : 'Foo',
|
||||
'barcode' : 'Foo',
|
||||
'encodedby' : 'Foo',
|
||||
'albumsort' : 'Foo',
|
||||
'albumartistsort' : 'Foo',
|
||||
'artistsort' : 'Foo',
|
||||
'titlesort' : 'Foo',
|
||||
'musicbrainz_trackid' : 'Foo',
|
||||
'musicbrainz_albumid' : 'Foo',
|
||||
'musicbrainz_artistid' : 'Foo',
|
||||
'musicbrainz_albumartistid' : 'Foo',
|
||||
'musicbrainz_trmid' : 'Foo',
|
||||
'musicbrainz_discid' : 'Foo',
|
||||
'musicip_puid' : 'Foo',
|
||||
'releasestatus' : 'Foo',
|
||||
'releasetype' : 'Foo',
|
||||
}
|
||||
|
||||
|
||||
class MP3Test(FormatsTest):
|
||||
original = os.path.join('test', 'data', 'test.mp3')
|
||||
tags = [
|
||||
('album', ['Foo', 'Bar']),
|
||||
('album', ['1']),
|
||||
('title', ['Foo']),
|
||||
('artist', ['Foo']),
|
||||
('albumartist', ['Foo']),
|
||||
('date', ['2004-00-00']),
|
||||
('artist', ['Foo']),
|
||||
('composer', ['Foo']),
|
||||
('lyricist', ['Foo']),
|
||||
('conductor', ['Foo']),
|
||||
('performer:guest vocal', ['Foo']),
|
||||
('remixer', ['Foo']),
|
||||
('engineer', ['Foo']),
|
||||
('producer', ['Foo']),
|
||||
('grouping', ['Foo']),
|
||||
('subtitle', ['Foo']),
|
||||
('discsubtitle', ['Foo']),
|
||||
('compilation', ['1']),
|
||||
#('comment', ['Foo']),
|
||||
('genre', ['Foo']),
|
||||
('bpm', ['Foo']),
|
||||
('mood', ['Foo']),
|
||||
('isrc', ['Foo']),
|
||||
('copyright', ['Foo']),
|
||||
tags = {
|
||||
'album' : 'Foo Bar',
|
||||
'album' : '1',
|
||||
'title' : 'Foo',
|
||||
'artist' : 'Foo',
|
||||
'albumartist' : 'Foo',
|
||||
'date' : '2004',
|
||||
'artist' : 'Foo',
|
||||
'composer' : 'Foo',
|
||||
'lyricist' : 'Foo',
|
||||
'conductor' : 'Foo',
|
||||
'performer:guest vocal' : 'Foo',
|
||||
'remixer' : 'Foo',
|
||||
'engineer' : 'Foo',
|
||||
'producer' : 'Foo',
|
||||
'grouping' : 'Foo',
|
||||
'subtitle' : 'Foo',
|
||||
'discsubtitle' : 'Foo',
|
||||
'compilation' : '1',
|
||||
#'comment' : 'Foo',
|
||||
'genre' : 'Foo',
|
||||
'bpm' : 'Foo',
|
||||
'mood' : 'Foo',
|
||||
'isrc' : 'Foo',
|
||||
'copyright' : 'Foo',
|
||||
# TODO
|
||||
('lyrics', ['Foo'], []),
|
||||
('media', ['Foo']),
|
||||
('label', ['Foo']),
|
||||
('catalognumber', ['Foo']),
|
||||
('barcode', ['Foo']),
|
||||
('encodedby', ['Foo']),
|
||||
('albumsort', ['Foo']),
|
||||
('albumartistsort', ['Foo']),
|
||||
('artistsort', ['Foo']),
|
||||
('titlesort', ['Foo']),
|
||||
('musicbrainz_trackid', ['Foo']),
|
||||
('musicbrainz_albumid', ['Foo']),
|
||||
('musicbrainz_artistid', ['Foo']),
|
||||
('musicbrainz_albumartistid', ['Foo']),
|
||||
('musicbrainz_trmid', ['Foo']),
|
||||
('musicbrainz_discid', ['Foo']),
|
||||
('musicip_puid', ['Foo']),
|
||||
('releasestatus', ['Foo']),
|
||||
('releasetype', ['Foo']),
|
||||
]
|
||||
# 'lyrics' : 'Foo',
|
||||
'media' : 'Foo',
|
||||
'label' : 'Foo',
|
||||
'catalognumber' : 'Foo',
|
||||
'barcode' : 'Foo',
|
||||
'encodedby' : 'Foo',
|
||||
'albumsort' : 'Foo',
|
||||
'albumartistsort' : 'Foo',
|
||||
'artistsort' : 'Foo',
|
||||
'titlesort' : 'Foo',
|
||||
'musicbrainz_trackid' : 'Foo',
|
||||
'musicbrainz_albumid' : 'Foo',
|
||||
'musicbrainz_artistid' : 'Foo',
|
||||
'musicbrainz_albumartistid' : 'Foo',
|
||||
'musicbrainz_trmid' : 'Foo',
|
||||
'musicbrainz_discid' : 'Foo',
|
||||
'musicip_puid' : 'Foo',
|
||||
'releasestatus' : 'Foo',
|
||||
'releasetype' : 'Foo',
|
||||
}
|
||||
|
||||
|
||||
class OggVorbisTest(FormatsTest):
|
||||
original = os.path.join('test', 'data', 'test.ogg')
|
||||
tags = [
|
||||
('album', ['Foo', 'Bar']),
|
||||
('album', ['1']),
|
||||
('title', ['Foo']),
|
||||
('artist', ['Foo']),
|
||||
('albumartist', ['Foo']),
|
||||
('date', ['2004-00-00'], ['2004']),
|
||||
('artist', ['Foo']),
|
||||
('composer', ['Foo']),
|
||||
('lyricist', ['Foo']),
|
||||
('conductor', ['Foo']),
|
||||
('performer:guest vocal', ['Foo']),
|
||||
('remixer', ['Foo']),
|
||||
('engineer', ['Foo']),
|
||||
('producer', ['Foo']),
|
||||
('grouping', ['Foo']),
|
||||
('subtitle', ['Foo']),
|
||||
('discsubtitle', ['Foo']),
|
||||
('compilation', ['1']),
|
||||
('comment', ['Foo']),
|
||||
('genre', ['Foo']),
|
||||
('bpm', ['Foo']),
|
||||
('mood', ['Foo']),
|
||||
('isrc', ['Foo']),
|
||||
('copyright', ['Foo']),
|
||||
('lyrics', ['Foo']),
|
||||
('media', ['Foo']),
|
||||
('label', ['Foo']),
|
||||
('catalognumber', ['Foo']),
|
||||
('barcode', ['Foo']),
|
||||
('encodedby', ['Foo']),
|
||||
('albumsort', ['Foo']),
|
||||
('albumartistsort', ['Foo']),
|
||||
('artistsort', ['Foo']),
|
||||
('titlesort', ['Foo']),
|
||||
('musicbrainz_trackid', ['Foo']),
|
||||
('musicbrainz_albumid', ['Foo']),
|
||||
('musicbrainz_artistid', ['Foo']),
|
||||
('musicbrainz_albumartistid', ['Foo']),
|
||||
('musicbrainz_trmid', ['Foo']),
|
||||
('musicbrainz_discid', ['Foo']),
|
||||
('musicip_puid', ['Foo']),
|
||||
('releasestatus', ['Foo']),
|
||||
('releasetype', ['Foo']),
|
||||
]
|
||||
tags = {
|
||||
'album' : 'Foo Bar',
|
||||
'album' : '1',
|
||||
'title' : 'Foo',
|
||||
'artist' : 'Foo',
|
||||
'albumartist' : 'Foo',
|
||||
'date' : '2004',
|
||||
'artist' : 'Foo',
|
||||
'composer' : 'Foo',
|
||||
'lyricist' : 'Foo',
|
||||
'conductor' : 'Foo',
|
||||
'performer:guest vocal' : 'Foo',
|
||||
'remixer' : 'Foo',
|
||||
'engineer' : 'Foo',
|
||||
'producer' : 'Foo',
|
||||
'grouping' : 'Foo',
|
||||
'subtitle' : 'Foo',
|
||||
'discsubtitle' : 'Foo',
|
||||
'compilation' : '1',
|
||||
'comment' : 'Foo',
|
||||
'genre' : 'Foo',
|
||||
'bpm' : 'Foo',
|
||||
'mood' : 'Foo',
|
||||
'isrc' : 'Foo',
|
||||
'copyright' : 'Foo',
|
||||
'lyrics' : 'Foo',
|
||||
'media' : 'Foo',
|
||||
'label' : 'Foo',
|
||||
'catalognumber' : 'Foo',
|
||||
'barcode' : 'Foo',
|
||||
'encodedby' : 'Foo',
|
||||
'albumsort' : 'Foo',
|
||||
'albumartistsort' : 'Foo',
|
||||
'artistsort' : 'Foo',
|
||||
'titlesort' : 'Foo',
|
||||
'musicbrainz_trackid' : 'Foo',
|
||||
'musicbrainz_albumid' : 'Foo',
|
||||
'musicbrainz_artistid' : 'Foo',
|
||||
'musicbrainz_albumartistid' : 'Foo',
|
||||
'musicbrainz_trmid' : 'Foo',
|
||||
'musicbrainz_discid' : 'Foo',
|
||||
'musicip_puid' : 'Foo',
|
||||
'releasestatus' : 'Foo',
|
||||
'releasetype' : 'Foo',
|
||||
}
|
||||
|
||||
|
||||
class MP4VorbisTest(FormatsTest):
|
||||
original = os.path.join('test', 'data', 'test.m4a')
|
||||
tags = [
|
||||
('album', ['Foo', 'Bar']),
|
||||
('album', ['1']),
|
||||
('title', ['Foo']),
|
||||
('artist', ['Foo']),
|
||||
('albumartist', ['Foo']),
|
||||
('date', ['2004-00-00']),
|
||||
('artist', ['Foo']),
|
||||
('composer', ['Foo']),
|
||||
('grouping', ['Foo']),
|
||||
('compilation', ['1']),
|
||||
('musicbrainz_trackid', ['Foo']),
|
||||
('musicbrainz_albumid', ['Foo']),
|
||||
('musicbrainz_artistid', ['Foo']),
|
||||
('musicbrainz_albumartistid', ['Foo']),
|
||||
('musicbrainz_trmid', ['Foo']),
|
||||
('musicbrainz_discid', ['Foo']),
|
||||
('musicip_puid', ['Foo']),
|
||||
('releasestatus', ['Foo']),
|
||||
('releasetype', ['Foo']),
|
||||
('encodedby', ['Foo']),
|
||||
('lyrics', ['Foo']),
|
||||
('copyright', ['Foo']),
|
||||
]
|
||||
tags = {
|
||||
'album' : 'Foo Bar',
|
||||
'album' : '1',
|
||||
'title' : 'Foo',
|
||||
'artist' : 'Foo',
|
||||
'albumartist' : 'Foo',
|
||||
'date' : '2004-00-00',
|
||||
'artist' : 'Foo',
|
||||
'composer' : 'Foo',
|
||||
'grouping' : 'Foo',
|
||||
'compilation' : '1',
|
||||
'musicbrainz_trackid' : 'Foo',
|
||||
'musicbrainz_albumid' : 'Foo',
|
||||
'musicbrainz_artistid' : 'Foo',
|
||||
'musicbrainz_albumartistid' : 'Foo',
|
||||
'musicbrainz_trmid' : 'Foo',
|
||||
'musicbrainz_discid' : 'Foo',
|
||||
'musicip_puid' : 'Foo',
|
||||
'releasestatus' : 'Foo',
|
||||
'releasetype' : 'Foo',
|
||||
'encodedby' : 'Foo',
|
||||
'lyrics' : 'Foo',
|
||||
'copyright' : 'Foo',
|
||||
}
|
||||
|
||||
|
||||
class WavPackTest(FormatsTest):
|
||||
original = os.path.join('test', 'data', 'test.wv')
|
||||
tags = [
|
||||
('album', ['Foo', 'Bar']),
|
||||
('album', ['1']),
|
||||
('title', ['Foo']),
|
||||
('artist', ['Foo']),
|
||||
('albumartist', ['Foo']),
|
||||
('date', ['2004-00-00'], ['2004']),
|
||||
('artist', ['Foo']),
|
||||
('composer', ['Foo']),
|
||||
('lyricist', ['Foo']),
|
||||
('conductor', ['Foo']),
|
||||
('performer:guest vocal', ['Foo']),
|
||||
('remixer', ['Foo']),
|
||||
('engineer', ['Foo']),
|
||||
('producer', ['Foo']),
|
||||
('grouping', ['Foo']),
|
||||
('subtitle', ['Foo']),
|
||||
('discsubtitle', ['Foo']),
|
||||
('compilation', ['1']),
|
||||
('comment', ['Foo']),
|
||||
('genre', ['Foo']),
|
||||
('bpm', ['Foo']),
|
||||
('mood', ['Foo']),
|
||||
('isrc', ['Foo']),
|
||||
('copyright', ['Foo']),
|
||||
('lyrics', ['Foo']),
|
||||
('media', ['Foo']),
|
||||
('label', ['Foo']),
|
||||
('catalognumber', ['Foo']),
|
||||
('barcode', ['Foo']),
|
||||
('encodedby', ['Foo']),
|
||||
('albumsort', ['Foo']),
|
||||
('albumartistsort', ['Foo']),
|
||||
('artistsort', ['Foo']),
|
||||
('titlesort', ['Foo']),
|
||||
('musicbrainz_trackid', ['Foo']),
|
||||
('musicbrainz_albumid', ['Foo']),
|
||||
('musicbrainz_artistid', ['Foo']),
|
||||
('musicbrainz_albumartistid', ['Foo']),
|
||||
('musicbrainz_trmid', ['Foo']),
|
||||
('musicbrainz_discid', ['Foo']),
|
||||
('musicip_puid', ['Foo']),
|
||||
('releasestatus', ['Foo']),
|
||||
('releasetype', ['Foo']),
|
||||
]
|
||||
tags = {
|
||||
'album' : 'Foo Bar',
|
||||
'album' : '1',
|
||||
'title' : 'Foo',
|
||||
'artist' : 'Foo',
|
||||
'albumartist' : 'Foo',
|
||||
'date' : '2004',
|
||||
'artist' : 'Foo',
|
||||
'composer' : 'Foo',
|
||||
'lyricist' : 'Foo',
|
||||
'conductor' : 'Foo',
|
||||
'performer:guest vocal' : 'Foo',
|
||||
'remixer' : 'Foo',
|
||||
'engineer' : 'Foo',
|
||||
'producer' : 'Foo',
|
||||
'grouping' : 'Foo',
|
||||
'subtitle' : 'Foo',
|
||||
'discsubtitle' : 'Foo',
|
||||
'compilation' : '1',
|
||||
'comment' : 'Foo',
|
||||
'genre' : 'Foo',
|
||||
'bpm' : 'Foo',
|
||||
'mood' : 'Foo',
|
||||
'isrc' : 'Foo',
|
||||
'copyright' : 'Foo',
|
||||
'lyrics' : 'Foo',
|
||||
'media' : 'Foo',
|
||||
'label' : 'Foo',
|
||||
'catalognumber' : 'Foo',
|
||||
'barcode' : 'Foo',
|
||||
'encodedby' : 'Foo',
|
||||
'albumsort' : 'Foo',
|
||||
'albumartistsort' : 'Foo',
|
||||
'artistsort' : 'Foo',
|
||||
'titlesort' : 'Foo',
|
||||
'musicbrainz_trackid' : 'Foo',
|
||||
'musicbrainz_albumid' : 'Foo',
|
||||
'musicbrainz_artistid' : 'Foo',
|
||||
'musicbrainz_albumartistid' : 'Foo',
|
||||
'musicbrainz_trmid' : 'Foo',
|
||||
'musicbrainz_discid' : 'Foo',
|
||||
'musicip_puid' : 'Foo',
|
||||
'releasestatus' : 'Foo',
|
||||
'releasetype' : 'Foo',
|
||||
}
|
||||
|
||||
|
||||
class TestCoverArt(unittest.TestCase):
|
||||
@@ -310,20 +320,25 @@ class TestCoverArt(unittest.TestCase):
|
||||
self._set_up(filename)
|
||||
try:
|
||||
f = picard.formats.open(self.filename)
|
||||
f.metadata.clear()
|
||||
f.metadata.add_image("image/jpeg", "JFIFfoobar")
|
||||
f.save()
|
||||
# f.metadata.clear()
|
||||
# f.metadata.add_image("image/jpeg", "JFIFfoobar")
|
||||
metadata = Metadata()
|
||||
metadata.add_image("image/jpeg", "JFIFfoobar")
|
||||
f._save(self.filename, metadata)
|
||||
|
||||
f = picard.formats.open(self.filename)
|
||||
f._load()
|
||||
self.assertEqual(f.metadata.images[0][0], "image/jpeg")
|
||||
self.assertEqual(f.metadata.images[0][1], "JFIFfoobar")
|
||||
f._load(self.filename)
|
||||
self.assertEqual(metadata.images[0][0], "image/jpeg")
|
||||
self.assertEqual(metadata.images[0][1], "JFIFfoobar")
|
||||
|
||||
f = picard.formats.open(self.filename)
|
||||
f.metadata.clear()
|
||||
f.metadata.add_image("image/png", "PNGfoobar")
|
||||
f.save()
|
||||
metadata = Metadata()
|
||||
metadata.add_image("image/png", "PNGfoobar")
|
||||
f._save(self.filename, metadata)
|
||||
|
||||
f = picard.formats.open(self.filename)
|
||||
f._load()
|
||||
self.assertEqual(f.metadata.images[0][0], "image/png")
|
||||
self.assertEqual(f.metadata.images[0][1], "PNGfoobar")
|
||||
f._load(self.filename)
|
||||
self.assertEqual(metadata.images[0][0], "image/png")
|
||||
self.assertEqual(metadata.images[0][1], "PNGfoobar")
|
||||
finally:
|
||||
self._tear_down()
|
||||
|
||||
Reference in New Issue
Block a user