test_handlight.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 # Software License Agreement (BSD License)
00005 #
00006 # Copyright (c) 2014, Tokyo Opensource Robotics Kyokai Association
00007 # All rights reserved.
00008 #
00009 # Redistribution and use in source and binary forms, with or without
00010 # modification, are permitted provided that the following conditions
00011 # are met:
00012 #
00013 #  * Redistributions of source code must retain the above copyright
00014 #    notice, this list of conditions and the following disclaimer.
00015 #  * Redistributions in binary form must reproduce the above
00016 #    copyright notice, this list of conditions and the following
00017 #    disclaimer in the documentation and/or other materials provided
00018 #    with the distribution.
00019 #  * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
00020 #    names of its contributors may be used to endorse or promote products
00021 #    derived from this software without specific prior written permission.
00022 #
00023 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034 # POSSIBILITY OF SUCH DAMAGE.
00035 #
00036 # Author: Isaac I.Y. Saito
00037 
00038 import unittest
00039 
00040 import rostest
00041 
00042 from nextage_ros_bridge import nextage_client
00043 
00044 _GOINITIAL_TIME_MIDSPEED = 3  # second
00045 _PKG = 'nextage_ros_bridge'
00046 
00047 
00048 class TestNxoHandlight(unittest.TestCase):
00049     '''
00050     Test NextageClient with rostest. This does NOT test hardware (i.e. if DIO
00051     is connected and functioning); instead, this only verifies if the
00052     software works as to the given hardware spec.
00053 
00054     For tests involving hardware, follow
00055     https://github.com/start-jsk/rtmros_hironx/issues/272.
00056     '''
00057 
00058     @classmethod
00059     def setUpClass(cls):
00060         cls._robot = nextage_client.NextageClient()  # Latest (v0.5 or newer)
00061         cls._robot.init()
00062         cls._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
00063 
00064         # For older DIO version robot.
00065         cls._robot_04 = nextage_client.NextageClient()
00066         cls._robot_04.set_hand_version(version=cls._robot_04.HAND_VER_0_4_2)
00067         cls._robot_04.init()
00068         cls._robot_04.goInitial(_GOINITIAL_TIME_MIDSPEED)
00069 
00070     @classmethod
00071     def tearDownClass(cls):
00072         cls._robot.goInitial(_GOINITIAL_TIME_MIDSPEED)
00073         cls._robot_04.goInitial(_GOINITIAL_TIME_MIDSPEED)
00074 
00075     # On simulator, return of DIO methods should fail no matter what
00076     # argument is passed. So assertFalse doesn't do much...it works
00077     # to verify that the tested methods "run without error".
00078 
00079     def test_handlight_r_05(self):
00080         '''Testing software version 0.5 or newer'''
00081         if self._robot.simulation_mode:
00082             result = self._robot._hands.handlight_r(is_on=False)
00083             self.assertTrue(result)
00084         else:
00085             result = self._robot._hands.handlight_r(is_on=True)
00086             self.assertTrue(result)
00087 
00088     def test_handlight_r_04(self):
00089         if self._robot.simulation_mode:
00090             result = self._robot_04.handlight_r(is_on=False)
00091             self.assertTrue(result)
00092         else:
00093             result = self._robot_04.handlight_r(is_on=True)
00094             self.assertTrue(result)
00095 
00096     def test_handlight_l_05(self):
00097         '''Testing software version 0.5 or newer'''
00098         if self._robot.simulation_mode:
00099             result = self._robot._hands.handlight_l(is_on=False)
00100             self.assertFalse(result)
00101         else:
00102             result = self._robot._hands.handlight_l(is_on=True)
00103             self.assertTrue(result)
00104 
00105     def test_handlight_l_04(self):
00106         if self._robot.simulation_mode:
00107             result = self._robot_04.handlight_l(is_on=False)
00108             self.assertTrue(result)
00109         else:
00110             result = self._robot_04.handlight_l(is_on=True)
00111             self.assertTrue(result)
00112 
00113     def test_handlight_both_05(self):
00114         '''Testing software version 0.5 or newer'''
00115         if self._robot.simulation_mode:
00116             # Check if checking false works.
00117             result = self._robot._hands.handlight_both(is_on=False)
00118             self.assertFalse(result)
00119         else:
00120             result = self._robot._hands.handlight_both(is_on=True)
00121             self.assertTrue(result)
00122 
00123     def test_handlight_both_04(self):
00124         if self._robot.simulation_mode:
00125             # Check if checking false works.
00126             result = self._robot_04.handlight_both(is_on=False) and result
00127             self.assertFalse(result)
00128         else:
00129             result = self._robot_04.handlight_both(is_on=True) and result
00130             self.assertTrue(result)
00131 
00132 if __name__ == '__main__':
00133     rostest.rosrun(_PKG, 'test_nxo_handlight', TestNxoHandlight)


nextage_ros_bridge
Author(s): Isaac Isao Saito , Akio Ochiai
autogenerated on Wed May 15 2019 04:45:36