cc-4105: Made config object persist data after being garbage collected. Added more tests
This commit is contained in:
parent
76cac68fe7
commit
12aa76b0a8
6 changed files with 211 additions and 4 deletions
28
python_apps/media-monitor2/tests/config.py
Normal file
28
python_apps/media-monitor2/tests/config.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
import pprint
|
||||
|
||||
from media.monitor.config import MMConfig
|
||||
from media.monitor.exceptions import NoConfigFile, ConfigAccessViolation
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
class TestMMConfig(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.real_config = MMConfig("./test_config.cfg")
|
||||
#pp.pprint(self.real_config.cfg.dict)
|
||||
|
||||
def test_bad_config(self):
|
||||
self.assertRaises( NoConfigFile, lambda : MMConfig("/fake/stuff/here") )
|
||||
|
||||
def test_no_set(self):
|
||||
def myf(): self.real_config['bad'] = 'change'
|
||||
self.assertRaises( ConfigAccessViolation, myf )
|
||||
|
||||
def test_copying(self):
|
||||
k = 'list_value_testing'
|
||||
mycopy = self.real_config[k]
|
||||
mycopy.append("another element")
|
||||
self.assertTrue( len(mycopy) , len(self.real_config[k]) + 1 )
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
Loading…
Add table
Add a link
Reference in a new issue