-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: assign aggregated genre to album
Also, make autogenre command code reusable for running it on import.
- Loading branch information
1 parent
b68d6b1
commit a0e495a
Showing
5 changed files
with
155 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
from beetsplug.autogenre import _most_common | ||
|
||
class TestMostCommon(unittest.TestCase): | ||
|
||
def test_most_common(self): | ||
testcases = [ | ||
{ | ||
'name': 'empty', | ||
'input': [], | ||
'expected': None, | ||
}, | ||
{ | ||
'name': 'single', | ||
'input': ['genre 1'], | ||
'expected': 'genre 1', | ||
}, | ||
{ | ||
'name': 'first', | ||
'input': ['genre 1', 'genre 2', 'genre 3'], | ||
'expected': 'genre 1', | ||
}, | ||
{ | ||
'name': 'first not none', | ||
'input': [None, 'genre 1', 'genre 2', 'genre 3'], | ||
'expected': 'genre 1', | ||
}, | ||
{ | ||
'name': 'most common', | ||
'input': ['genre 1', 'genre 2', 'genre 2', 'genre 3'], | ||
'expected': 'genre 2', | ||
}, | ||
{ | ||
'name': 'first most common', | ||
'input': ['genre 1', 'genre 2', 'genre 2', 'genre 3', 'genre 3'], | ||
'expected': 'genre 2', | ||
}, | ||
] | ||
for c in testcases: | ||
info = "\ntest case '{}' input: {}".format(c['name'], c['input']) | ||
a = _most_common(c['input']) | ||
self.assertEqual(a, c['expected'], info) |