old_contents: #!/usr/bin/env python
  #encoding: utf-8
  import unittest, rostest
  import rosnode, rospy
  import time
  from pimouse_ros.msg import LightSensorValues
  
  class LightsensorTest(unittest.TestCase):
    def setUp(self):
      self.count = 0
      rospy.Subscriber('/lightsensors', LightSensorValues, self.callback)
      self.values = LightSensorValues()
    def callback(self, data):
      self.count += 1
      self.values = data
    def test_node_exist(self):
      nodes = rosnode.get_node_names()
      self.assertIn('/lightsensors', nodes, "node does not exist")
  
  if __name__ == '__main__':
    time.sleep(3)
    rospy.init_node('travis_test_lightsensors')
    rostest.rosrun('pimouse_ros', 'travis_test_lightsensors', LightsensorTest)
  
new_contents: #!/usr/bin/env python
  #encoding: utf-8
  import unittest, rostest
  import rosnode, rospy
  import time
  from pimouse_ros.msg import LightSensorValues
  
  class LightsensorTest(unittest.TestCase):
    def setUp(self):
      self.count = 0
      rospy.Subscriber('/lightsensors', LightSensorValues, self.callback)
      self.values = LightSensorValues()
    def callback(self, data):
      self.count += 1
      self.values = data
  
    def check_values(self, lf, ls, rs, rf):
      vs  = self.values
      self.assertEqual(vs.left_forward, lf, "different value: left_forward")
      self.assertEqual(vs.left_side, ls, "different value: left_side")
      self.assertEqual(vs.right_side, rs, "diffrent value: right_side")
      self.assertEqual(vs.right_forward, rf, "diffrent value: right_forward")
      self.assertEqual(vs.sum_all, lf + ls + rs + rf, "diffrent value: sum_all")
      self.assertEqual(vs.sum_forward, lf + rf, "diffrent value: sum_forward")
  
    def test_node_exist(self):
      nodes = rosnode.get_node_names()
      self.assertIn('/lightsensors', nodes, "node does not exist")
  
    def test_get_value(self):
      rospy.set_param('lightsensors_freq', 10)
      time.sleep(2)
      with open("/dev/rtlightsensor0", "w") as f:
          f.write("-1 0 123 4321\n")
      time.sleep(3)
      self.assertFalse(self.count == 0, "cannot subscribe the topic")
      self.check_values(4321, 123, 0, -1)
  
  if __name__ == '__main__':
    time.sleep(3)
    rospy.init_node('travis_test_lightsensors')
    rostest.rosrun('pimouse_ros', 'travis_test_lightsensors', LightsensorTest)
  
subject: add test for get_value