mirror of
https://github.com/beetbox/beets.git
synced 2026-01-29 03:26:28 +01:00
acousticbrainz: Test _map_data_to_scheme with real data
This commit is contained in:
parent
4586e2df5a
commit
51243240f6
2 changed files with 4151 additions and 2 deletions
4115
test/rsrc/acousticbrainz/data.json
Normal file
4115
test/rsrc/acousticbrainz/data.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -18,9 +18,12 @@
|
|||
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from test._common import unittest
|
||||
import json
|
||||
import os.path
|
||||
|
||||
from beetsplug.acousticbrainz import DefaultList, AcousticPlugin
|
||||
from test._common import unittest, RSRC
|
||||
|
||||
from beetsplug.acousticbrainz import DefaultList, AcousticPlugin, ABSCHEME
|
||||
|
||||
|
||||
class DefaultListTest(unittest.TestCase):
|
||||
|
|
@ -79,6 +82,37 @@ class MapDataToSchemeTest(unittest.TestCase):
|
|||
mapping = set(ab._map_data_to_scheme(data, scheme))
|
||||
self.assertEqual(mapping, {('attribute', 'part 1 part 2')})
|
||||
|
||||
def test_realistic(self):
|
||||
ab = AcousticPlugin()
|
||||
data_path = os.path.join(RSRC, b'acousticbrainz/data.json')
|
||||
with open(data_path) as res:
|
||||
data = json.load(res)
|
||||
mapping = set(ab._map_data_to_scheme(data, ABSCHEME))
|
||||
expected = {
|
||||
('chords_key', 'A'),
|
||||
('average_loudness', 0.815025985241),
|
||||
('mood_acoustic', 0.415711194277),
|
||||
('chords_changes_rate', 0.0445116683841),
|
||||
('tonal', 0.874250173569),
|
||||
('mood_sad', 0.299694597721),
|
||||
('bpm', 162.532119751),
|
||||
('gender', 'female'),
|
||||
('initial_key', 'A minor'),
|
||||
('chords_number_rate', 0.00194468453992),
|
||||
('mood_relaxed', 0.123632438481),
|
||||
('chords_scale', 'minor'),
|
||||
('voice_instrumental', 'instrumental'),
|
||||
('key_strength', 0.636936545372),
|
||||
('genre_rosamerica', 'roc'),
|
||||
('mood_party', 0.234383180737),
|
||||
('mood_aggressive', 0.0779221653938),
|
||||
('danceable', 0.143928021193),
|
||||
('rhythm', 'VienneseWaltz'),
|
||||
('mood_electronic', 0.339881360531),
|
||||
('mood_happy', 0.0894767045975)
|
||||
}
|
||||
self.assertEqual(mapping, expected)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue