test_sr_base.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 # import python libraries
00005 import logging
00006 import unittest
00007 
00008 # import pypi libraries
00009 from nose.tools import raises
00010 
00011 # import local libraries
00012 from rospeex_core import exceptions as ext
00013 from rospeex_core.sr.base.client import IClient
00014 from rospeex_core.sr.base.session import SessionState
00015 
00016 # setup logging
00017 FORMAT = '[%(levelname)s] %(message)s @%(filename)s:%(funcName)s:%(lineno)d'
00018 logging.basicConfig(format=FORMAT, level=logging.DEBUG)
00019 logger = logging.getLogger(__name__)
00020 
00021 
00022 class TestSpeechRecognitionClient(unittest.TestCase):
00023     def setUp(self):
00024         pass
00025 
00026     @raises(TypeError)
00027     def test_request_invalid_not_implement(self):
00028         IClient()
00029 
00030 
00031 class TestSessionState(unittest.TestCase):
00032     def setUp(self):
00033         pass
00034 
00035     def test_to_str(self):
00036         assert SessionState.to_str(SessionState.ERROR) == 'ERROR'
00037         assert SessionState.to_str(SessionState.INIT) == 'INIT'
00038         assert SessionState.to_str(SessionState.START) == 'START'
00039         assert SessionState.to_str(SessionState.DATA) == 'DATA'
00040         assert SessionState.to_str(SessionState.END) == 'END'
00041         assert SessionState.to_str(-100) == 'UNKNOWN STATE'
00042 
00043     def test_check_valid_state(self):
00044         SessionState.check_state(SessionState.ERROR)
00045         SessionState.check_state(SessionState.INIT)
00046         SessionState.check_state(SessionState.START)
00047         SessionState.check_state(SessionState.DATA)
00048         SessionState.check_state(SessionState.END)
00049 
00050     @raises(ext.InvalidSessionStateException)
00051     def test_check_invalid_state(self):
00052         SessionState.check_state(-100)
00053 
00054 
00055 if __name__ == '__main__':
00056     import rosunit
00057     rosunit.unitrun(
00058         'rospeex_core',
00059         'sr_base_client',
00060         TestSpeechRecognitionClient,
00061         None,
00062         coverage_packages=['rospeex_core']
00063     )
00064 
00065     rosunit.unitrun(
00066         'rospeex_core',
00067         'sr_base_session_state',
00068         TestSessionState,
00069         None,
00070         coverage_packages=['rospeex_core']
00071     )


rospeex_core
Author(s): Komei Sugiura
autogenerated on Thu Apr 20 2017 03:08:53