cc-4105: finished test suite for manager

This commit is contained in:
Rudi Grinberg 2012-07-25 11:33:08 -04:00
parent 4950f13cf2
commit 25c03822b3
2 changed files with 31 additions and 14 deletions

View file

@ -1,10 +1,15 @@
import unittest
from media.monitor.manager import Manager
def add_paths(m,paths):
for path in paths:
m.add_watch_directory(path)
class TestManager(unittest.TestCase):
def setUp(self):
self.opath = "/home/rudi/Airtime/python_apps/media-monitor2/tests/"
self.ppath = "/home/rudi/Airtime/python_apps/media-monitor2/media/"
self.paths = [self.opath, self.ppath]
def test_init(self):
man = Manager()
@ -23,6 +28,21 @@ class TestManager(unittest.TestCase):
man = Manager()
man.set_store_path( self.opath )
self.assertEqual( man.store_path, self.opath )
man.set_store_path( self.ppath )
self.assertEqual( man.store_path, self.ppath )
def test_add_watch_directory(self):
man = Manager()
add_paths(man, self.paths)
for path in self.paths:
self.assertTrue( man.has_watch(path) )
def test_remove_watch_directory(self):
man = Manager()
add_paths(man, self.paths)
for path in self.paths:
self.assertTrue( man.has_watch(path) )
man.remove_watch_directory( path )
self.assertTrue( not man.has_watch(path) )
if __name__ == '__main__': unittest.main()