Esempio n. 1
0
    def test_001_get_command_kwargs(self, _build_args):
        # Arguments parsed
        args = Mock()
        args.config = 'config.json'
        args.jid = 'test@localhost'
        args.password = '******'
        args.server = '127.0.0.1:5555'
        args.api = 'localhost:8082'
        args.logging = 'DEBUG'
        _build_args.return_value = args

        # Result
        kwargs = get_command_kwargs()
        expected = {
            'bus': {
                'host': '127.0.0.1',
                'port': 5555,
                'jid': 'test@localhost',
                'password': '******'
            },
            'api': {
                'host': 'localhost',
                'port': 8082
            },
            'config': 'config.json',
            'log': {
                'root': {
                    'level': 'DEBUG'
                }
            }
        }
        self.assertEqual(kwargs, expected)
Esempio n. 2
0
    def test_001_get_command_kwargs(self, _build_args):
        # Arguments parsed
        args = Mock()
        args.config = 'config.json'
        args.jid = 'test@localhost'
        args.password = '******'
        args.server = '127.0.0.1:5555'
        args.api = 'localhost:8082'
        args.logging = 'DEBUG'
        _build_args.return_value = args

        # Result
        kwargs = get_command_kwargs()
        expected = {
            'bus': {
                'host': '127.0.0.1',
                'port': 5555,
                'jid': 'test@localhost',
                'password': '******'
            },
            'api': {
                'host': 'localhost',
                'port': 8082
            },
            'config': 'config.json',
            'log': {
                'root': {
                    'level': 'DEBUG'
                }
            }
        }
        self.assertEqual(kwargs, expected)
Esempio n. 3
0
    def __init__(self, **kwargs):
        # List of configuration schemas
        self._schemas = []

        # Get configuration from multiple sources and register base schema
        kwargs = kwargs or get_command_kwargs()
        self.config_filename = kwargs.get('config', DEFAULT_CONF_FILE)
        self._config = get_full_config(**kwargs)
        self.register_schema(self.BASE_CONF_SCHEMA)

        # Initialize logging
        logging.config.dictConfig(self._config['log'])

        self.loop = asyncio.get_event_loop() or asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        self._services = ServiceManager(self)
        self._services.add('api', Exposer(self))

        # Add bus service if in conf file
        if self._config.get('bus') is not None:
            self._services.add('bus', Bus(self))

        self.is_stopping = False