Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. import logging as log
  2. log.basicConfig(level=log.DEBUG,
  3.                 format='%(asctime)s %(levelname)s %(message)s',
  4.                 filename=__name__ + '.log',
  5.                 filemode='w')
  6. import unittest
  7. import sys
  8. import os
  9.  
  10. os.chdir(os.getcwd()[0:-6]) # ouch that hurts!
  11. STDOUT_REDIRECT_FILE = 'tests/' + __name__ + '2.log'
  12.  
  13. if os.path.exists(STDOUT_REDIRECT_FILE):
  14.     os.remove(STDOUT_REDIRECT_FILE)
  15.  
  16. #--------------------------------------------------------------------------
  17.  
  18. from Main import CanDaemon
  19. canDaemon = CanDaemon()
  20.  
  21. class MainCmdTests(unittest.TestCase):
  22.    
  23.     def setUp(self):
  24.         """Call before every test case."""
  25.         sys.stdout = open(STDOUT_REDIRECT_FILE, 'a')
  26.  
  27.     def tearDown(self):
  28.         """Call after every test case."""
  29.         sys.stdout = sys.__stdout__
  30.    
  31.     def testCmdBasic(self):
  32.         log.debug('testCmdBasic')
  33.         canDaemon.helpCmd()
  34.  
  35.     def testImportFilter(self):
  36.         log.debug('testImportFilter')
  37.         canDaemon.filterCmd('DefaultFilter')
  38.  
  39.     def testImportSpace(self):
  40.         log.debug('testImportSpace')
  41.         canDaemon.stateCmd('DefaultStateSpace')
  42.  
  43.