replaygain test: add basic per_disc testcase

The per_disc codepath is currently not exercised at all by the tests.
This test is not very meaningful, but better than nothing.
This commit is contained in:
wisp3rwind 2021-03-20 11:46:10 +01:00
parent 81396412ef
commit 80f7c58e5a
2 changed files with 13 additions and 2 deletions

View file

@ -1096,7 +1096,6 @@ class ReplayGainPlugin(BeetsPlugin):
# FIXME: Consider renaming the configuration option and deprecating the
# old name 'overwrite'.
self.force_on_import = self.config['overwrite'].get(bool)
self.per_disc = self.config['per_disc'].get(bool)
# Remember which backend is used for CLI feedback
self.backend_name = self.config['backend'].as_str()
@ -1234,7 +1233,7 @@ class ReplayGainPlugin(BeetsPlugin):
self._log.info('analyzing {0}', album)
discs = {}
if self.per_disc:
if self.config['per_disc'].get(bool):
for item in album.items():
if discs.get(item.disc) is None:
discs[item.disc] = []

View file

@ -169,6 +169,18 @@ class ReplayGainCliTestBase(TestHelper):
self.assertNotEqual(gain_relative_to_84, gain_relative_to_89)
def test_per_disc(self):
# Use the per_disc option and add a little more concurrency.
album = self._add_album(track_count=4, disc_count=3)
self.config['replaygain']['per_disc'] = True
self.run_command('replaygain', '-a')
# FIXME: Add fixtures with known track/album gain (within a suitable
# tolerance) so that we can actually check per-disc operation here.
for item in album.items():
self.assertIsNotNone(item.rg_track_gain)
self.assertIsNotNone(item.rg_album_gain)
@unittest.skipIf(not GST_AVAILABLE, 'gstreamer cannot be found')
class ReplayGainGstCliTest(ReplayGainCliTestBase, unittest.TestCase):