def test_args_nonexisting_files(self):
     args = [
         'prog', 'data', '-c', 'test_config.json', '-i', 'DC1101EW', '-t',
         'Dataset Title', '-f', 'not-real.json'
     ]
     with patch.object(sys, 'argv', args):
         args_manager = ArgsManager()
         with self.assertRaises(OSError):
             args_manager.decode_arguments()
 def test_valid_args(self):
     args = [
         'prog', 'data', '-q', 'COUNTRY, SEX', '-d', 'Usual-Residents',
         '-i', 'DC1101EW', '-t', 'Dataset Title', '-y'
     ]
     with patch.object(sys, 'argv', args):
         args_manager = ArgsManager()
         arguments = args_manager.decode_arguments()
         self.assertEqual(arguments.dataset_id, 'DC1101EW')
         self.assertEqual(arguments.dataset_title, 'Dataset Title')
         self.assertEqual(arguments.query_variables, ['COUNTRY', 'SEX'])
         self.assertEqual(arguments.query_dataset, 'Usual-Residents')
         self.assertTrue(arguments.suppress_prompts)
         self.assertFalse(arguments.verbose)
Ejemplo n.º 3
0
def collect_arguments() -> Arguments:
    """
    Use the Args Manager to establish the arguments for given run.

    :return: An instance of `Arguments` containing the argument data established for a given run.
    """

    with ArgsManager() as am:
        arguments = am.decode_arguments()

    if arguments.debug:
        stream_handler = logging.StreamHandler(sys.stdout)
        stream_handler.setLevel(logging.DEBUG)
        logger.addHandler(stream_handler)
    elif arguments.verbose:
        stream_handler = logging.StreamHandler(sys.stdout)
        stream_handler.setLevel(logging.INFO)
        logger.addHandler(stream_handler)

    if arguments.log_file is not None:
        logger.handlers.remove(file_handler)
        new_file_handler = logging.FileHandler(arguments.log_file)
        new_file_handler.setFormatter(formatter)
        logger.addHandler(new_file_handler)

    return arguments
 def test_args_existing_files(self):
     args = [
         'prog', 'data', '-f', 'test_config.json', '-c', 'test_config.json',
         '-i', 'DC1101EW', '-t', 'Dataset Title', '-v'
     ]
     with patch.object(sys, 'argv', args):
         args_manager = ArgsManager()
         arguments = args_manager.decode_arguments()
         self.assertEqual(arguments.dataset_id, 'DC1101EW')
         self.assertEqual(arguments.dataset_title, 'Dataset Title')
         self.assertEqual(arguments.query_variables, None)
         self.assertEqual(arguments.query_dataset, None)
         self.assertEqual(arguments.filename, 'test_config.json')
         self.assertEqual(arguments.config_file, 'test_config.json')
         self.assertFalse(arguments.suppress_prompts)
         self.assertTrue(arguments.verbose)
         self.assertIsInstance(arguments, Arguments)
 def test_invalid_args(self):
     args = [
         'prog', 'data', '-q', 'COUNTRY, , SEX', '-d', 'Usual-Residents',
         '-i', 'DC1101EW', '-t', 'Dataset Title'
     ]
     with patch.object(sys, 'argv', args):
         args_manager = ArgsManager()
         with self.assertRaises(ValueError):
             args_manager.decode_arguments()
     args = [
         'prog', 'invalid', '-q', 'COUNTRY', '-d', 'Usual-Residents', '-i',
         'DC1101EW', '-t', 'Dataset Title'
     ]
     with patch.object(sys, 'argv', args):
         args_manager = ArgsManager()
         with self.assertRaises(ValueError):
             args_manager.decode_arguments()
Ejemplo n.º 6
0
"""obstacle_avoid_test controller."""

from robot_manager import RobotManager
from args_manager import ArgsManager
import numpy as np

np.random.seed(13482736)
argsManager = ArgsManager()

robotManager = RobotManager(argsManager.process_args())
robotManager.execute()