Files
whipper-gui/morituri/test/test_common_config.py
Matt Robinson 3f9cc77e30 Persist False value for defeat_cache correctly
If cdparanoia can't work around the audio caching of a drive,
defeats_cache = False is written to the config.  However, when it is
read back the string 'False' ends up being converted to True (as it is
not an empty string).

This corrects the behaviour when reading the value back and adds tests
to make sure that both True and False can be correctly retrieved from
the config.
2016-12-31 17:48:21 +00:00

69 lines
2.3 KiB
Python

# -*- Mode: Python; test-case-name: morituri.test.test_common_config -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import tempfile
from morituri.common import config
from morituri.test import common as tcommon
class ConfigTestCase(tcommon.TestCase):
def setUp(self):
fd, self._path = tempfile.mkstemp(suffix=u'.morituri.test.config')
os.close(fd)
self._config = config.Config(self._path)
def tearDown(self):
os.unlink(self._path)
def testAddReadOffset(self):
self.assertRaises(KeyError,
self._config.getReadOffset, 'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self._config.setReadOffset('PLEXTOR ', 'DVDR PX-L890SA', '1.05', 6)
# getting it from memory should work
offset = self._config.getReadOffset('PLEXTOR ', 'DVDR PX-L890SA',
'1.05')
self.assertEquals(offset, 6)
# and so should getting it after reading it again
self._config.open()
offset = self._config.getReadOffset('PLEXTOR ', 'DVDR PX-L890SA',
'1.05')
self.assertEquals(offset, 6)
def testAddReadOffsetSpaced(self):
self.assertRaises(KeyError,
self._config.getReadOffset, 'Slimtype', 'eSAU208 2 ', 'ML03')
self._config.setReadOffset('Slimtype', 'eSAU208 2 ', 'ML03', 6)
# getting it from memory should work
offset = self._config.getReadOffset(
'Slimtype', 'eSAU208 2 ', 'ML03')
self.assertEquals(offset, 6)
# and so should getting it after reading it again
self._config.open()
offset = self._config.getReadOffset(
'Slimtype', 'eSAU208 2 ', 'ML03')
self.assertEquals(offset, 6)
def testDefeatsCache(self):
self.assertRaises(KeyError, self._config.getDefeatsCache,
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self._config.setDefeatsCache(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05', False)
defeats = self._config.getDefeatsCache(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self.assertEquals(defeats, False)
self._config.setDefeatsCache(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05', True)
defeats = self._config.getDefeatsCache(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self.assertEquals(defeats, True)