Example #1
0
 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),
                 ('moods_mirex', "Cluster3"), ('timbre', "bright")}
     self.assertEqual(mapping, expected)
Example #2
0
 def test_invalid_characters(self):
     ab = AcousticPlugin()
     data = {'key 1': "['?\x32\x96 233474']", 'key 2': '\xb9\x42'}
     scheme = {'key 1': 'attribute 1', 'key 2': 'attribute 2'}
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute 1', "['?\x32\x96 233474']"),
                                ('attribute 2', '\xb9\x42')})
Example #3
0
 def test_basic(self):
     ab = AcousticPlugin()
     data = {'key 1': 'value 1', 'key 2': 'value 2'}
     scheme = {'key 1': 'attribute 1', 'key 2': 'attribute 2'}
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute 1', 'value 1'),
                                ('attribute 2', 'value 2')})
Example #4
0
 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)
Example #5
0
 def test_basic(self):
     ab = AcousticPlugin()
     data = {'key 1': 'value 1', 'key 2': 'value 2'}
     scheme = {'key 1': 'attribute 1', 'key 2': 'attribute 2'}
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute 1', 'value 1'),
                                ('attribute 2', 'value 2')})
Example #6
0
 def test_recurse(self):
     ab = AcousticPlugin()
     data = {
         'key': 'value',
         'group': {
             'subkey': 'subvalue',
             'subgroup': {
                 'subsubkey': 'subsubvalue'
             }
         }
     }
     scheme = {
         'key': 'attribute 1',
         'group': {
             'subkey': 'attribute 2',
             'subgroup': {
                 'subsubkey': 'attribute 3'
             }
         }
     }
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(
         mapping, {('attribute 1', 'value'), ('attribute 2', 'subvalue'),
                   ('attribute 3', 'subsubvalue')})
Example #7
0
 def test_recurse(self):
     ab = AcousticPlugin()
     data = {
         'key': 'value',
         'group': {
             'subkey': 'subvalue',
             'subgroup': {
                 'subsubkey': 'subsubvalue'
             }
         }
     }
     scheme = {
         'key': 'attribute 1',
         'group': {
             'subkey': 'attribute 2',
             'subgroup': {
                 'subsubkey': 'attribute 3'
             }
         }
     }
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute 1', 'value'),
                                ('attribute 2', 'subvalue'),
                                ('attribute 3', 'subsubvalue')})
Example #8
0
 def test_composite(self):
     ab = AcousticPlugin()
     data = {'key 1': 'part 1', 'key 2': 'part 2'}
     scheme = {'key 1': ('attribute', 0), 'key 2': ('attribute', 1)}
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute', 'part 1 part 2')})
Example #9
0
 def test_composite(self):
     ab = AcousticPlugin()
     data = {'key 1': 'part 1', 'key 2': 'part 2'}
     scheme = {'key 1': ('attribute', 0), 'key 2': ('attribute', 1)}
     mapping = set(ab._map_data_to_scheme(data, scheme))
     self.assertEqual(mapping, {('attribute', 'part 1 part 2')})