Esempio n. 1
0
 def test_start_stop_capabilities(self):
     # fail to start interface without a provider
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'no_provider_pkg/Minimal2', '')
     # fail to start interface which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'minimal_pkg/Minimal2', 'minimal_pkg/minimal')
     # start an interface by explicitly giving a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', 'minimal_pkg/minimal')
     # Wait a reasonable amount of time for roslaunch to startup
     # If it doesn't fully startup you get a traceback, but it will not affect the test
     rospy.sleep(2)
     # get list of running capabilities
     resp = call_service('/capability_server/get_running_capabilities')
     assert len(resp.running_capabilities) > 0, resp
     capability = resp.running_capabilities[0].capability
     assert 'minimal_pkg/Minimal' == capability.capability, capability.capability
     # stop the capability started above
     call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
     # fail to stop a capability which isn't running
     with assert_raises(ServiceException):
         call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
     # fail to start a capability with a provider which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', 'minimal_pkg/minimal2')
     # start a capability without specifying a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', '')
     call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
     # start a provider which depends on an interface without specifiying a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/SpecificMinimal',
                  'no_provider_pkg/specific_minimal2')
     call_service('/capability_server/stop_capability', 'minimal_pkg/SpecificMinimal')
 def test_introspection_services(self):
     # Reload
     call_service('/capability_server/reload_capabilities')
     # get interafaces
     resp = call_service('/capability_server/get_interfaces')
     assert 'minimal_pkg/Minimal' in resp.interfaces, resp
     # get providers by interface
     resp = call_service('/capability_server/get_providers', 'minimal_pkg/Minimal', False)
     assert 'minimal_pkg/minimal' in resp.providers, resp
     assert 'minimal_pkg/specific_minimal' not in resp.providers, resp
     # get providers by interface, include semantic interfaces
     resp = call_service('/capability_server/get_providers', 'minimal_pkg/Minimal', True)
     assert 'minimal_pkg/specific_minimal' in resp.providers, resp
     # get all providers
     resp = call_service('/capability_server/get_providers', '', False)
     assert 'minimal_pkg/minimal' in resp.providers, resp
     assert resp.default_provider == '', resp
     # fail to get providers for non-existent interface
     with assert_raises(ServiceException):
         call_service('/capability_server/get_providers', 'not_a_pkg/NotAnInterface', False)
     # get semantic interfaces
     resp = call_service('/capability_server/get_semantic_interfaces')
     assert 'minimal_pkg/SpecificMinimal' in resp.semantic_interfaces, resp
     # get semantic interfaces by interface
     resp = call_service('/capability_server/get_semantic_interfaces', 'minimal_pkg/Minimal')
     assert 'minimal_pkg/SpecificMinimal' in resp.semantic_interfaces, resp
     # get nodelet manager name
     resp = call_service('/capability_server/get_nodelet_manager_name')
     assert resp.nodelet_manager_name == '/capability_server_nodelet_manager', resp
 def test_introspection_services(self):
     # Reload
     call_service('/capability_server/reload_capabilities')
     # get interafaces
     resp = call_service('/capability_server/get_interfaces')
     assert 'minimal_pkg/Minimal' in resp.interfaces, resp
     # get providers by interface
     resp = call_service('/capability_server/get_providers',
                         'minimal_pkg/Minimal', False)
     assert 'minimal_pkg/minimal' in resp.providers, resp
     assert 'minimal_pkg/specific_minimal' not in resp.providers, resp
     # get providers by interface, include semantic interfaces
     resp = call_service('/capability_server/get_providers',
                         'minimal_pkg/Minimal', True)
     assert 'minimal_pkg/specific_minimal' in resp.providers, resp
     # get all providers
     resp = call_service('/capability_server/get_providers', '', False)
     assert 'minimal_pkg/minimal' in resp.providers, resp
     assert resp.default_provider == '', resp
     # fail to get providers for non-existent interface
     with assert_raises(ServiceException):
         call_service('/capability_server/get_providers',
                      'not_a_pkg/NotAnInterface', False)
     # get semantic interfaces
     resp = call_service('/capability_server/get_semantic_interfaces')
     assert 'minimal_pkg/SpecificMinimal' in resp.semantic_interfaces, resp
     # get semantic interfaces by interface
     resp = call_service('/capability_server/get_semantic_interfaces',
                         'minimal_pkg/Minimal')
     assert 'minimal_pkg/SpecificMinimal' in resp.semantic_interfaces, resp
     # get nodelet manager name
     resp = call_service('/capability_server/get_nodelet_manager_name')
     assert resp.nodelet_manager_name == '/capability_server_nodelet_manager', resp
Esempio n. 4
0
 def test_start_stop_capabilities(self):
     # fail to start interface without a provider
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'no_provider_pkg/Minimal2', '')
     # fail to start interface which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'minimal_pkg/Minimal2', 'minimal_pkg/minimal')
     # start an interface by explicitly giving a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/Minimal', 'minimal_pkg/minimal')
     self.ensure_capability_started('minimal_pkg/Minimal')
     # get list of running capabilities
     resp = call_service('/capability_server/get_running_capabilities')
     assert len(resp.running_capabilities) > 0, resp
     capability = resp.running_capabilities[0].capability
     assert 'minimal_pkg/Minimal' == capability.capability, capability.capability
     # stop the capability started above
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/Minimal')
     self.ensure_capability_stopped('minimal_pkg/Minimal')
     # fail to stop a capability which isn't running
     with assert_raises(ServiceException):
         resp = call_service('/capability_server/stop_capability',
                             'minimal_pkg/Minimal')
         print(resp)
     # fail to start a capability with a provider which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'minimal_pkg/Minimal', 'minimal_pkg/minimal2')
     # start a capability without specifying a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/Minimal', '')
     self.ensure_capability_started('minimal_pkg/Minimal')
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/Minimal')
     self.ensure_capability_stopped('minimal_pkg/Minimal')
     # start a provider which depends on an interface without specifiying a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/SpecificMinimal',
                  'no_provider_pkg/specific_minimal2')
     self.ensure_capability_started('minimal_pkg/SpecificMinimal')
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/SpecificMinimal')
     self.ensure_capability_stopped('minimal_pkg/SpecificMinimal')
Esempio n. 5
0
 def test_invalid_default_provider(self):
     minimal_dir = os.path.join(TEST_DIR, 'unit', 'discovery_workspaces', 'minimal')
     ros_package_path = [minimal_dir]
     rospy.set_param('~defaults/minimal_pkg/Minimal', 'minimal_pkg/not_a_valid_provider')
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
Esempio n. 6
0
 def test_no_default_provider_pedantic(self):
     no_default_provider = os.path.join(TEST_DIR, 'rostest', 'test_server', 'no_default_provider')
     ros_package_path = [no_default_provider]
     rospy.set_param('~missing_default_provider_is_an_error', True)
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
Esempio n. 7
0
 def test_no_default_provider_pedantic(self):
     no_default_provider = os.path.join(TEST_DIR, 'rostest', 'test_server',
                                        'no_default_provider')
     ros_package_path = [no_default_provider]
     rospy.set_param('~missing_default_provider_is_an_error', True)
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
Esempio n. 8
0
 def test_wrong_default_provider(self):
     dc_dir = os.path.join(TEST_DIR, 'unit', 'discovery_workspaces', 'dependent_capabilities')
     ros_package_path = [dc_dir]
     rospy.set_param('~defaults/navigation_capability/Navigation',
                     'differential_mobile_base_capability/faux_differential_mobile_base')
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
Esempio n. 9
0
 def test_service_discovery(self):
     # get spec index via a service call (This tests the handling in the server)
     si, errors = spec_index_from_service()
     assert not errors
     assert 'minimal_pkg/Minimal' in si.interfaces
     resp = call_service('/capability_server/get_capability_spec', 'minimal_pkg/Minimal')
     assert resp.capability_spec.package == 'minimal_pkg', resp.capability_spec.package
     assert 'name: Minimal' in resp.capability_spec.content, resp.capability_spec.content
     with assert_raises(ServiceException):
         resp = call_service('/capability_server/get_capability_spec', 'minimal_pkg/DoesNotExist')
Esempio n. 10
0
 def test_invalid_default_provider(self):
     minimal_dir = os.path.join(TEST_DIR, 'unit', 'discovery_workspaces',
                                'minimal')
     ros_package_path = [minimal_dir]
     rospy.set_param('~defaults/minimal_pkg/Minimal',
                     'minimal_pkg/not_a_valid_provider')
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
 def test_start_stop_capabilities(self):
     # fail to start interface without a provider
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'no_provider_pkg/Minimal2', '')
     # fail to start interface which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'minimal_pkg/Minimal2', 'minimal_pkg/minimal')
     # start an interface by explicitly giving a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/Minimal', 'minimal_pkg/minimal')
     # Wait a reasonable amount of time for roslaunch to startup
     # If it doesn't fully startup you get a traceback, but it will not affect the test
     rospy.sleep(2)
     # get list of running capabilities
     resp = call_service('/capability_server/get_running_capabilities')
     assert len(resp.running_capabilities) > 0, resp
     capability = resp.running_capabilities[0].capability
     assert 'minimal_pkg/Minimal' == capability.capability, capability.capability
     # stop the capability started above
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/Minimal')
     # fail to stop a capability which isn't running
     with assert_raises(ServiceException):
         call_service('/capability_server/stop_capability',
                      'minimal_pkg/Minimal')
     # fail to start a capability with a provider which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability',
                      'minimal_pkg/Minimal', 'minimal_pkg/minimal2')
     # start a capability without specifying a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/Minimal', '')
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/Minimal')
     # start a provider which depends on an interface without specifiying a provider
     call_service('/capability_server/start_capability',
                  'minimal_pkg/SpecificMinimal',
                  'no_provider_pkg/specific_minimal2')
     call_service('/capability_server/stop_capability',
                  'minimal_pkg/SpecificMinimal')
Esempio n. 12
0
 def test_wrong_default_provider(self):
     dc_dir = os.path.join(TEST_DIR, 'unit', 'discovery_workspaces',
                           'dependent_capabilities')
     ros_package_path = [dc_dir]
     rospy.set_param(
         '~defaults/navigation_capability/Navigation',
         'differential_mobile_base_capability/faux_differential_mobile_base'
     )
     capability_server = server.CapabilityServer(ros_package_path)
     capability_server._CapabilityServer__load_capabilities()
     with assert_raises(SystemExit):
         capability_server._CapabilityServer__populate_default_providers()
 def test_service_discovery(self):
     # get spec index via a service call (This tests the handling in the server)
     si, errors = spec_index_from_service()
     assert not errors
     assert 'minimal_pkg/Minimal' in si.interfaces
     resp = call_service('/capability_server/get_capability_spec',
                         'minimal_pkg/Minimal')
     assert resp.capability_spec.package == 'minimal_pkg', resp.capability_spec.package
     assert 'name: Minimal' in resp.capability_spec.content, resp.capability_spec.content
     with assert_raises(ServiceException):
         resp = call_service('/capability_server/get_capability_spec',
                             'minimal_pkg/DoesNotExist')
 def test_start_stop_capabilities(self):
     # fail to start interface without a provider
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'no_provider_pkg/Minimal2', '')
     # fail to start interface which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'minimal_pkg/Minimal2', 'minimal_pkg/minimal')
     # start an interface by explicitly giving a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', 'minimal_pkg/minimal')
     self.ensure_capability_started('minimal_pkg/Minimal')
     # get list of running capabilities
     resp = call_service('/capability_server/get_running_capabilities')
     assert len(resp.running_capabilities) > 0, resp
     capability = resp.running_capabilities[0].capability
     assert 'minimal_pkg/Minimal' == capability.capability, capability.capability
     # stop the capability started above
     call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
     self.ensure_capability_stopped('minimal_pkg/Minimal')
     # fail to stop a capability which isn't running
     with assert_raises(ServiceException):
         resp = call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
         print(resp)
     # fail to start a capability with a provider which doesn't exist
     with assert_raises(ServiceException):
         call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', 'minimal_pkg/minimal2')
     # start a capability without specifying a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/Minimal', '')
     self.ensure_capability_started('minimal_pkg/Minimal')
     call_service('/capability_server/stop_capability', 'minimal_pkg/Minimal')
     self.ensure_capability_stopped('minimal_pkg/Minimal')
     # start a provider which depends on an interface without specifiying a provider
     call_service('/capability_server/start_capability', 'minimal_pkg/SpecificMinimal',
                  'no_provider_pkg/specific_minimal2')
     self.ensure_capability_started('minimal_pkg/SpecificMinimal')
     call_service('/capability_server/stop_capability', 'minimal_pkg/SpecificMinimal')
     self.ensure_capability_stopped('minimal_pkg/SpecificMinimal')