Esempio n. 1
0
    def test_load_conf_has_all_options(self):
        # Tests if ini file has all expected options

        cfg = util.load_conf(self.config_file)

        self.assertTrue(
            cfg.has_option('redfish', 'schema_dir'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'schema_dir', 'redfish', self.config_file))
        self.assertTrue(
            cfg.has_option('redfish', 'indent_json'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'indent_json', 'redfish', self.config_file))
        self.assertTrue(
            cfg.has_option('oneview_config', 'ip'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'ip', 'oneview_config', self.config_file))
        self.assertTrue(
            cfg.has_option('oneview_config', 'api_version'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'schema_dir', 'oneview_config', self.config_file))
        self.assertTrue(
            cfg.has_option('credentials', 'userName'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'userName', 'credentials', self.config_file))
        self.assertTrue(
            cfg.has_option('credentials', 'password'),
            msg='Option {} not found in section {} in ini file {}'.format(
                'password', 'credentials', self.config_file))
Esempio n. 2
0
    def test_load_registries_valid_registry_dir_valid_dict(self):
        # Tests loading registry files from redfish.conf

        cfg = util.load_conf(self.config_file)
        registries = dict(cfg.items('registry'))

        try:
            registry_dict = util.load_registry(self.registry_dir, registries)
            self.assertIsInstance(registry_dict, collections.OrderedDict)
        except Exception as e:
            self.fail('Failed to load registries files: {}'.format(e.msg))
Esempio n. 3
0
    def test_load_conf_has_all_expect_sessions(self):
        # Tests if ini file has all expected sections
        cfg = util.load_conf(self.config_file)

        self.assertTrue(cfg.has_section('redfish'),
                        msg='Section {} not found in ini file {}'.format(
                            'redfish', self.config_file))
        self.assertTrue(cfg.has_section('oneview_config'),
                        msg='Section {} not found in ini file {}'.format(
                            'oneview_config', self.config_file))
        self.assertTrue(cfg.has_section('credentials'),
                        msg='Section {} not found in ini file {}'.format(
                            'credentials', self.config_file))
        self.assertTrue(cfg.has_section('schemas'),
                        msg='Section {} not found in ini file {}'.format(
                            'schemas', self.config_file))
        self.assertTrue(cfg.has_section('registry'),
                        msg='Section {} not found in ini file {}'.format(
                            'registry', self.config_file))
        self.assertTrue(cfg.has_section('event_service'),
                        msg='Section {} not found in ini file {}'.format(
                            'event_service', self.config_file))
Esempio n. 4
0
 def test_load_conf_valid_config_file(self):
     # Tests if passing a valid file returns a object
     self.assertIsInstance(util.load_conf(self.config_file),
                           configparser.ConfigParser)
Esempio n. 5
0
 def test_load_conf_invalid_config_file(self):
     # Tests if passing a file that does not exists returns false.
     try:
         util.load_conf('non-exist.conf')
     except Exception as e:
         self.assertIsInstance(e, OneViewRedfishResourceNotFoundError)