test_DiagnosticStatusWrapper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 @author Brice Rebsamen <brice [dot] rebsamen [gmail]>
6 """
7 
8 import roslib
9 roslib.load_manifest('diagnostic_updater')
10 import rospy
11 from diagnostic_updater import *
12 import unittest
13 
14 
15 class TestDiagnosticStatusWrapper(unittest.TestCase):
16  def test_init_empty(self):
18  self.assertEqual(d.level, 0)
19  self.assertEqual(d.message, "")
20  self.assertEqual(d.values, [])
21 
22  def test_init_lvl_msg(self):
23  d = DiagnosticStatusWrapper(level=1, message="test")
24  self.assertEqual(d.level, 1)
25  self.assertEqual(d.message, "test")
26  self.assertEqual(d.values, [])
27 
30  d.summary(1, "test")
31  self.assertEqual(d.level, 1)
32  self.assertEqual(d.message, "test")
33 
34  def test_summary_dmsg(self):
35  d = DiagnosticStatusWrapper(level=0, message="ok")
36  m = DiagnosticStatus(level=1, message="warn")
37  d.summary(m)
38  self.assertEqual(d.level, 1)
39  self.assertEqual(d.message, "warn")
40 
41  def test_clear_summary(self):
42  d = DiagnosticStatusWrapper(level=0, message="ok")
43  d.clearSummary()
44  self.assertEqual(d.level, 0)
45  self.assertEqual(d.message, "")
46 
48  d = DiagnosticStatusWrapper(level=0, message="ok")
49  d.mergeSummary(1, "warn")
50  self.assertEqual(d.level, 1)
51  self.assertEqual(d.message, "warn")
52 
53  d.mergeSummary(2, "err")
54  self.assertEqual(d.level, 2)
55  self.assertEqual(d.message, "warn; err")
56 
58  d = DiagnosticStatusWrapper(level=0, message="ok")
59  m = DiagnosticStatus(level=1, message="warn")
60  d.mergeSummary(m)
61  self.assertEqual(d.level, 1)
62  self.assertEqual(d.message, "warn")
63 
64  m = DiagnosticStatus(level=2, message="err")
65  d.mergeSummary(m)
66  self.assertEqual(d.level, 2)
67  self.assertEqual(d.message, "warn; err")
68 
69  def test_add(self):
71  d.add('key','val')
72  self.assertEqual(d.values[0].key, 'key')
73  self.assertEqual(d.values[0].value, 'val')
74 
75 if __name__ == '__main__':
76  unittest.main()
Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update...


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Thu Oct 8 2020 03:19:34