mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-26 19:29:01 +00:00
Convert release_type_scores option to ListOption
We had a space-separated list of name,value tuples ("Album 0.5 Other 0.4"),
and two helper functions to load and save data in the correct format
(`load_release_type_scores` and `save_release_type_scores`).
Since option is converted to recently-introduced ListOption, data is now saved
as a list of tuples, eventually converted to dict when needed.
It simplifies code, and also prevents an issue if it comes we have a release group type
with a space in its name.
An upgrade hook was added to handle this change on Picard upgrade.
This commit is contained in:
@@ -92,36 +92,6 @@ class FormatTimeTest(unittest.TestCase):
|
||||
self.assertEqual("2:59", util.format_time(179499))
|
||||
|
||||
|
||||
class LoadReleaseTypeScoresTest(unittest.TestCase):
|
||||
|
||||
def test_valid(self):
|
||||
release_type_score_config = "Album 1.0 Single 0.5 EP 0.5 Compilation 0.5 Soundtrack 0.5 Spokenword 0.5 Interview 0.2 Audiobook 0.0 Live 0.5 Remix 0.4 Other 0.0"
|
||||
release_type_scores = util.load_release_type_scores(release_type_score_config)
|
||||
self.assertEqual(1.0, release_type_scores["Album"])
|
||||
self.assertEqual(0.5, release_type_scores["Single"])
|
||||
self.assertEqual(0.2, release_type_scores["Interview"])
|
||||
self.assertEqual(0.0, release_type_scores["Audiobook"])
|
||||
self.assertEqual(0.4, release_type_scores["Remix"])
|
||||
|
||||
def test_invalid(self):
|
||||
release_type_score_config = "Album 1.0 Other"
|
||||
release_type_scores = util.load_release_type_scores(release_type_score_config)
|
||||
self.assertEqual(1.0, release_type_scores["Album"])
|
||||
self.assertEqual(0.0, release_type_scores["Other"])
|
||||
|
||||
|
||||
class SaveReleaseTypeScoresTest(unittest.TestCase):
|
||||
|
||||
def test(self):
|
||||
expected = "Album 1.00 Single 0.50 Other 0.00"
|
||||
scores = {"Album": 1.0, "Single": 0.5, "Other": 0.0}
|
||||
saved_scores = util.save_release_type_scores(scores)
|
||||
self.assertTrue("Album 1.00" in saved_scores)
|
||||
self.assertTrue("Single 0.50" in saved_scores)
|
||||
self.assertTrue("Other 0.00" in saved_scores)
|
||||
self.assertEqual(6, len(saved_scores.split()))
|
||||
|
||||
|
||||
class HiddenPathTest(unittest.TestCase):
|
||||
|
||||
def test(self):
|
||||
|
||||
Reference in New Issue
Block a user