test_DiagnosticStatusWrapper.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 """
00005 @author Brice Rebsamen <brice [dot] rebsamen [gmail]>
00006 """
00007 
00008 import roslib
00009 roslib.load_manifest('diagnostic_updater')
00010 import rospy
00011 from diagnostic_updater import *
00012 import unittest
00013 
00014 
00015 class TestDiagnosticStatusWrapper(unittest.TestCase):
00016     def test_init_empty(self):
00017         d = DiagnosticStatusWrapper()
00018         self.assertEqual(d.level, 0)
00019         self.assertEqual(d.message, "")
00020         self.assertEqual(d.values, [])
00021 
00022     def test_init_lvl_msg(self):
00023         d = DiagnosticStatusWrapper(level=1, message="test")
00024         self.assertEqual(d.level, 1)
00025         self.assertEqual(d.message, "test")
00026         self.assertEqual(d.values, [])
00027 
00028     def test_summary_lvl_msg(self):
00029         d = DiagnosticStatusWrapper()
00030         d.summary(1, "test")
00031         self.assertEqual(d.level, 1)
00032         self.assertEqual(d.message, "test")
00033 
00034     def test_summary_dmsg(self):
00035         d = DiagnosticStatusWrapper(level=0, message="ok")
00036         m = DiagnosticStatus(level=1, message="warn")
00037         d.summary(m)
00038         self.assertEqual(d.level, 1)
00039         self.assertEqual(d.message, "warn")
00040 
00041     def test_clear_summary(self):
00042         d = DiagnosticStatusWrapper(level=0, message="ok")
00043         d.clearSummary()
00044         self.assertEqual(d.level, 0)
00045         self.assertEqual(d.message, "")
00046 
00047     def test_merge_summary_lvl_msg(self):
00048         d = DiagnosticStatusWrapper(level=0, message="ok")
00049         d.mergeSummary(1, "warn")
00050         self.assertEqual(d.level, 1)
00051         self.assertEqual(d.message, "warn")
00052 
00053         d.mergeSummary(2, "err")
00054         self.assertEqual(d.level, 2)
00055         self.assertEqual(d.message, "warn; err")
00056 
00057     def test_merge_summary_dmsg(self):
00058         d = DiagnosticStatusWrapper(level=0, message="ok")
00059         m = DiagnosticStatus(level=1, message="warn")
00060         d.mergeSummary(m)
00061         self.assertEqual(d.level, 1)
00062         self.assertEqual(d.message, "warn")
00063 
00064         m = DiagnosticStatus(level=2, message="err")
00065         d.mergeSummary(m)
00066         self.assertEqual(d.level, 2)
00067         self.assertEqual(d.message, "warn; err")
00068 
00069     def test_add(self):
00070         d = DiagnosticStatusWrapper()
00071         d.add('key','val')
00072         self.assertEqual(d.values[0].key, 'key')
00073         self.assertEqual(d.values[0].value, 'val')
00074 
00075 if __name__ == '__main__':
00076     unittest.main()


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Mon Aug 14 2017 02:52:20