예제 #1
0
 def test_convert_dict_to_ini(self):
     self.assertEqual(functest_utils.convert_dict_to_ini({}), "")
     self.assertEqual(functest_utils.convert_dict_to_ini({"a": "b"}), "a:b")
     value = functest_utils.convert_dict_to_ini({"a": "b", "c": "d"})
     self.assertTrue(value in ('a:b,c:d', 'c:d,a:b'))
     with self.assertRaises(AssertionError):
         functest_utils.convert_list_to_ini("")
예제 #2
0
 def update_scenario_section(self):
     """Update scenario section in tempest.conf"""
     rconfig = configparser.RawConfigParser()
     rconfig.read(self.conf_file)
     filename = getattr(config.CONF, '{}_image'.format(self.case_name),
                        self.filename)
     if not rconfig.has_section('scenario'):
         rconfig.add_section('scenario')
     rconfig.set('scenario', 'img_file', os.path.basename(filename))
     rconfig.set('scenario', 'img_dir', os.path.dirname(filename))
     rconfig.set(
         'scenario', 'img_disk_format',
         getattr(config.CONF, '{}_image_format'.format(self.case_name),
                 self.image_format))
     extra_properties = self.extra_properties.copy()
     if env.get('IMAGE_PROPERTIES'):
         extra_properties.update(
             functest_utils.convert_ini_to_dict(
                 env.get('IMAGE_PROPERTIES')))
     extra_properties.update(
         getattr(config.CONF, '{}_extra_properties'.format(self.case_name),
                 {}))
     rconfig.set('scenario', 'img_properties',
                 functest_utils.convert_dict_to_ini(extra_properties))
     with open(self.conf_file, 'wb') as config_file:
         rconfig.write(config_file)