def test_get_loaded_files(self):
     ls = LaunchServicer()
     response_stream = ls.GetLoadedFiles(lmsg.Empty(), DummyContext())
     items = [response for response in response_stream]
     self.assertEqual(
         len(items), 0,
         "The list of loaded launch files on startup is not empty!")
示例#2
0
 def get_loaded_files(self):
     request = lmsg.Empty()
     response = self.lm_stub.GetLoadedFiles(request, timeout=settings.GRPC_TIMEOUT)
     result = []
     for loaded_file in response:
         args = {arg.name: arg.value for arg in loaded_file.args}
         result.append((loaded_file.package, loaded_file.path, args, loaded_file.masteruri, loaded_file.host))
     return result
 def ResetPackageCache(self, request, context):
     result = lmsg.Empty()
     reset_package_cache()
     return result
示例#4
0
 def ResetPackageCache(self, request, context):
     rospy.logdebug('ResetPackageCache request:\n%s' % str(request))
     result = lmsg.Empty()
     reset_package_cache()
     return result
示例#5
0
 def reset_package_path(self):
     request = lmsg.Empty()
     self.lm_stub.ResetPackageCache(request, timeout=settings.GRPC_TIMEOUT)
    def test_load_launch(self):
        ls = LaunchServicer()
        path = ''
        args = {}
        request_args = True
        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='fkie_node_manager_daemon',
                                   launch='no_file.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code,
            lmsg.ReturnStatus.StatusType.Value('FILE_NOT_FOUND'),
            "wrong status code if launch file not exists, result: %d, expected: %d, reported error: %s"
            % (response.status.code,
               lmsg.ReturnStatus.StatusType.Value('FILE_NOT_FOUND'),
               response.status.error_msg))
        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='unknonwn_package',
                                   launch='no_file.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code,
            lmsg.ReturnStatus.StatusType.Value('FILE_NOT_FOUND'),
            "wrong status code if package not exists, result: %d, expected: %d, reported error: %s"
            % (response.status.code,
               lmsg.ReturnStatus.StatusType.Value('FILE_NOT_FOUND'),
               response.status.error_msg))
        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='fkie_node_manager_daemon',
                                   launch='description_example.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code,
            lmsg.ReturnStatus.StatusType.Value('MULTIPLE_LAUNCHES'),
            "wrong status code for multiple launch files, result: %d, expected: %d, reported error: %s"
            % (response.status.code,
               lmsg.ReturnStatus.StatusType.Value('MULTIPLE_LAUNCHES'),
               response.status.error_msg))
        self.assertEqual(
            len(response.path), 2,
            "wrong count of multiple launch files, result: %d, expected: %d" %
            (len(response.path), 2))
        path = interpret_path(
            "$(find fkie_node_manager_daemon)/tests/resources/description_example.launch"
        )
        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='fkie_node_manager_daemon',
                                   launch='description_example.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code,
            lmsg.ReturnStatus.StatusType.Value('PARAMS_REQUIRED'),
            "wrong status code for request arguments, result: %d, expected: %d, reported error: %s"
            % (response.status.code,
               lmsg.ReturnStatus.StatusType.Value('PARAMS_REQUIRED'),
               response.status.error_msg))
        args = {arg.name: arg.value for arg in response.args}
        request_args = False
        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='fkie_node_manager_daemon',
                                   launch='description_example.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code, lmsg.ReturnStatus.StatusType.Value('OK'),
            "wrong status code on successful load, result: %d, expected: %d, reported error: %s"
            % (response.status.code, lmsg.ReturnStatus.StatusType.Value('OK'),
               response.status.error_msg))

        response = ls.LoadLaunch(
            lmsg.LoadLaunchRequest(package='fkie_node_manager_daemon',
                                   launch='description_example.launch',
                                   path=path,
                                   request_args=request_args), DummyContext())
        self.assertEqual(
            response.status.code,
            lmsg.ReturnStatus.StatusType.Value('ALREADY_OPEN'),
            "wrong status code if file is already open, result: %d, expected: %d, reported error: %s"
            % (response.status.code,
               lmsg.ReturnStatus.StatusType.Value('ALREADY_OPEN'),
               response.status.error_msg))
        self.assertEqual(
            response.path[0], path,
            "Wrong returned path in ALREADY_OPEN reply, expected: %s, got: %s"
            % (response.path[0], path))

        # test loaded file
        response_stream = ls.GetLoadedFiles(lmsg.Empty(), DummyContext())
        items = [response for response in response_stream]
        self.assertEqual(
            len(items), 1,
            "The count of loaded files after successful load is wrong")
        self.assertEqual(
            items[0].path, path,
            "Wrong reported loaded file path, got: %s, expected: %s" %
            (items[0].path, path))
        self.assertEqual(
            items[0].package, 'fkie_node_manager_daemon',
            "Wrong reported loaded package, got: %s, expected: %s" %
            (items[0].package, 'fkie_node_manager_daemon'))
        self.assertEqual(
            items[0].launch, 'description_example.launch',
            "Wrong reported loaded launch, got: %s, expected: %s" %
            (items[0].launch, 'description_example.launch'))