44 _request_class = rospy.AnyMsg
45 _response_class = rospy.AnyMsg
50 self.assert_(isinstance(rospy.service.ServiceException(), Exception))
53 class MockService(rospy.service._Service):
54 def __init__(self, name, service_class, uri):
55 rospy.service._Service.__init__(self, name, service_class)
58 from rospy.service
import ServiceManager
60 self.assertEquals({}, sm.map)
65 self.assertEquals([], sm.get_services())
67 self.assertEquals([], sm.get_services())
70 mock = MockService(
'/serv', MockServiceClass,
"rosrpc://uri:1")
71 mock2 = MockService(
'/serv', MockServiceClass,
"rosrpc://uri:2")
73 sm.register(
'/serv', mock)
74 self.assertEquals(mock, sm.get_service(
'/serv'))
75 self.assertEquals([(
'/serv', mock.uri)], sm.get_services())
77 sm.register(
'/serv', mock2)
78 self.fail(
"duplicate reg should fail")
79 except rospy.service.ServiceException:
pass 82 self.assertEquals([], sm.get_services())
85 sm.register(
'/serv', mock)
86 sm.unregister(
'/serv', mock2)
87 self.assertEquals(mock, sm.get_service(
'/serv'))
89 sm.register(
'/serv2', mock2)
90 self.assertEquals(mock, sm.get_service(
'/serv'))
91 self.assertEquals(mock2, sm.get_service(
'/serv2'))
92 self.assert_((
'/serv', mock.uri)
in sm.get_services())
93 self.assert_((
'/serv2', mock2.uri)
in sm.get_services())
95 sm.unregister(
'/serv', mock)
96 self.assertEquals([(
'/serv2', mock2.uri)], sm.get_services())
97 sm.unregister(
'/serv2', mock2)
98 self.assertEquals([], sm.get_services())
def test_ServiceException(self)
def test_ServiceManager(self)