def test_update_param_info(self):
     pi = {}
     ConfigurationLoader.update_param_info(
         pi, {
             'parameters': {
                 'p1': 1,
                 'p2': u'2',
                 'p3': '3',
                 'p4': ['1', '2', '3', '4'],
                 'p5': False,
                 'p6': -3.33,
                 'p7': {
                     'val': '34',
                     'type': 'str',
                     'desc': 'Some desc'
                 }
             }
         })
     for p in ('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7'):
         self.assertIn(p, pi)
         for f in ('val', 'type', 'desc'):
             self.assertIn(f, pi[p])
     for s in (('p1', 'int', 1), ('p2', 'str', u'2'), ('p3', 'str', '3'),
               ('p4', 'str', ['1', '2', '3', '4']), ('p5', 'bool', False),
               ('p6', 'float', -3.33), ('p7', 'str', '34')):
         self.assertEqual(pi[s[0]]['type'], s[1])
         self.assertEqual(pi[s[0]]['val'], s[2])
    def load_configuration(self):
        """Loads configuration specified by a user on a command line.

        At this moment, DLBS has already loaded standard configuration (if `discard_default_config` flag is not
        present). DLBS will try to load user configuration from `config` file (if not None) overwriting default
        parameters. Then, it will try to load user provided parameters (`params`, `vars` and `extensions`) that will
        overwrite existing configuration.

        If `plan` file is present, it will be loaded if `action` is `run`.
        """
        if self.config_file is not None:
            logging.debug('Loading configuration from: %s', self.config_file)
            with open(self.config_file) as file_obj:
                user_config = json.load(file_obj)
                # Update parameter information from user configuration.
                ConfigurationLoader.update_param_info(self.param_info,
                                                      user_config,
                                                      is_user_config=True)
                # Update existing benchmark configuration.
                ConfigurationLoader.update(
                    self.config, ConfigurationLoader.remove_info(user_config))
        if self.plan_file is not None and self.action == 'run':
            logging.debug('Loading plan from: %s', self.plan_file)
            with open(self.plan_file) as plan_file:
                self.plan = json.load(plan_file)
 def load_configuration(self):
     """Loads configuration specified by a user on a command line."""
     if self.config_file is not None:
         logging.debug('Loading configuration from: %s', self.config_file)
         with open(self.config_file) as file_obj:
             user_config = json.load(file_obj)
             # Update parameter information from user configuration.
             ConfigurationLoader.update_param_info(self.param_info,
                                                   user_config,
                                                   is_user_config=True)
             # Update existing benchmark configuration.
             ConfigurationLoader.update(
                 self.config, ConfigurationLoader.remove_info(user_config))
     if self.plan_file is not None and self.action == 'run':
         logging.debug('Loading plan from: %s', self.plan_file)
         with open(self.plan_file) as plan_file:
             self.plan = json.load(plan_file)