Browse Source

Fix typo in description, improve readability

master
Felix 4 years ago
parent
commit
16849734f5
2 changed files with 12 additions and 28 deletions
  1. +2
    -5
      tangoinfo.py
  2. +10
    -23
      tests.py

+ 2
- 5
tangoinfo.py View File

@ -2,11 +2,8 @@
PLUGIN_NAME = "Tango.info Adapter"
PLUGIN_AUTHOR = "Felix Elsner"
PLUGIN_DESCRIPTION = """
<p>Load genre, date and vocalist tags from the online database
<a href"http://tango.info">tango.info</a>.</p>
<p>This plugin uses web scraping, but only once per album. In so doing
it does not cause unnecessary server load for either MusicBrainz.org
or tango.info</p>
<p>Load <code>genre</code>, <code>date</code> and <code>vocalist</code> tags
from the online database <a href="http://tango.info">tango.info</a>.</p>
"""
PLUGIN_VERSION = "0.1.6"
PLUGIN_API_VERSIONS = ["1.3.0", "1.4.0"]


+ 10
- 23
tests.py View File

@ -4,7 +4,7 @@
Testing for tangoinfo.py, with some fixes to get around the wrong version
error when running headless.
python2 only since picard is not py3k ready.
python2 only since picard is not py3k ready yet.
Run with `pytest tests.py`
"""
@ -56,7 +56,7 @@ class FakeTagger(tangoinfo.TangoInfoTagger):
class FakeTrack(object):
"""
A fake track object providing dummy iterfiles() and getters/setters.
A fake track object providing dummy iterfiles() and metadata.
"""
def __init__(self, id_, metadata=None):
@ -68,15 +68,6 @@ class FakeTrack(object):
# No need to test writing to files
return []
# Intercept calls(unused)
def get(self, item, default=None):
return self.metadata.get(item, default)
def __getitem__(self, item):
return self.metadata.get(item)
def __setitem__(self, key, item):
print('%s : setting: %s' % (self._id, key))
self.metadata[key] = item
def __repr__(self):
return '<FakeTrack %s> %s' % (self._id, unicode(self.metadata))
@ -85,15 +76,7 @@ class FakeAlbum(object):
def __init__(self, id_, new_tracks):
self._id = id_
self._requests = 0
self._nn = new_tracks
# Getters/setters for eventual debug inspection
@property
def _new_tracks(self):
return self._nn
@_new_tracks.setter
def _new_tracks(self, tracks_):
self._nn = tracks_
self._new_tracks = new_tracks
def _finalize_loading(self, dummy):
return
@ -118,7 +101,7 @@ def test_barcode_process_metadata():
albuminfo = taggerclass.barcode_process_metadata(barcode, page)
assert albuminfo['07798145106390-1-19'].get('date') == '1937-12-09'
assert albuminfo['07798145106390-1-19'].get('date') == u'1937-12-09'
assert len(albuminfo.keys()) == 23
return sorted(albuminfo.items())
@ -126,6 +109,7 @@ def test_barcode_process_metadata():
def test_add_tangoinfo_data():
"""
Test add_tangoinfo_data()
"""
taggerclass = FakeTagger()
barcode = '7798145106390'
@ -133,7 +117,6 @@ def test_add_tangoinfo_data():
releasexmlnode = 'fakereleasenode'
# Set up fake album
albumtracks = []
for i in range(1, 24):
fakealbumtrack = FakeTrack(id_='%s-1-%d' % (barcode, i),
@ -143,6 +126,7 @@ def test_add_tangoinfo_data():
album = FakeAlbum(id_='fakeid', new_tracks=albumtracks)
# Run plugin
loaded_tracks = []
for i in range(1, 24):
taggerclass.add_tangoinfo_data(album, album._new_tracks[-1].metadata,
@ -151,12 +135,15 @@ def test_add_tangoinfo_data():
loaded_tracks.append(loaded_track)
loaded_tracks = sorted(loaded_tracks,
key=lambda x: x.metadata['tracknumber'])
key=lambda track: track.metadata['tracknumber'])
# Start assertions
# Track 1: Don Juan
assert loaded_tracks[0].metadata.get('genre') == u'Tango'
# Track 2: Pasión
assert loaded_tracks[1].metadata.get('genre') == u'Vals'
# Track 22: Valsecito de antes
assert loaded_tracks[21].metadata.get('date') == u'1937-08-31'
# Output test data for visual inspection


Loading…
Cancel
Save