def test_parse_config(self): dirname = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0] config_file_path = os.path.join(dirname, "conductor.conf") # Read configuration file and check correct parameters values config_dict = parse_config(config_file_path, "conductor") self.assertEquals(config_dict["device_packaging"], "rpm") self.assertEquals(config_dict["custom_config_folder"], "/etc/ots/conductor") self.assertEquals(config_dict["pre_test_info_commands_debian"], "'initctl list', 'dpkg -l'") self.assertEquals(config_dict["pre_test_info_commands_rpm"], "'chkconfig', 'rpm -qa'") self.assertEquals( config_dict["pre_test_info_commands"], "'uname -a', 'pwd', 'uptime', 'ps', 'lsmod',\n" "'top -n1 -b', 'df', 'ifconfig', 'route -n',\n" "'printenv'") self.assertEquals(config_dict["files_fetched_after_testing"], "\"/var/log/messages\"") self.assertEquals(config_dict["tmp_path"], "/tmp/") # Check that parameter update works (_update_config_items fuction) current_config = { 'device_packaging': 'rpm', 'pre_test_info_commands_debian': "'initctl lst', 'dpkg -o'" } config_dict = parse_config(config_file_path, "conductor", current_config) self.assertEquals(config_dict["device_packaging"], "rpm") self.assertEquals(config_dict["pre_test_info_commands_debian"], "'initctl list', 'dpkg -l'")
def test_parse_config(self): dirname = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0] config_file_path = os.path.join(dirname, "conductor.conf") # Read configuration file and check correct parameters values config_dict = parse_config(config_file_path, "conductor") self.assertEquals(config_dict["device_packaging"], "rpm") self.assertEquals(config_dict["custom_config_folder"], "/etc/ots/conductor") self.assertEquals(config_dict["pre_test_info_commands_debian"], "'initctl list', 'dpkg -l'") self.assertEquals(config_dict["pre_test_info_commands_rpm"], "'chkconfig', 'rpm -qa'") self.assertEquals(config_dict["pre_test_info_commands"], "'uname -a', 'pwd', 'uptime', 'ps', 'lsmod',\n" "'top -n1 -b', 'df', 'ifconfig', 'route -n',\n" "'printenv'") self.assertEquals(config_dict["files_fetched_after_testing"], "\"/var/log/messages\"") self.assertEquals(config_dict["tmp_path"], "/tmp/") # Check that parameter update works (_update_config_items fuction) current_config = {'device_packaging': 'rpm', 'pre_test_info_commands_debian': "'initctl lst', 'dpkg -o'"} config_dict = parse_config(config_file_path, "conductor", current_config) self.assertEquals(config_dict["device_packaging"], "rpm") self.assertEquals(config_dict["pre_test_info_commands_debian"], "'initctl list', 'dpkg -l'")
def _parse_conductor_config(config_file, current_config_dict=None): """ Read and parse conductor configuration file. If config_file is None or does not exist, default_file is tried. If neither of the two files exists, raise exception. Returns dictionary. """ if not os.path.isfile(config_file): raise Exception("Configuration file missing") if not current_config_dict: current_config_dict = {} # Make sure these parameters will be parsed as lists. for conf_param in ['files_fetched_after_testing', \ 'pre_test_info_commands_debian', \ 'pre_test_info_commands_rpm', \ 'pre_test_info_commands']: current_config_dict[conf_param] = [] return parse_config(config_file, "conductor", current_config_dict)
def _parse_conductor_config(config_file, current_config_dict=None): """ Read and parse conductor configuration file. If config_file is None or does not exist, default_file is tried. If neither of the two files exists, raise exception. Returns dictionary. """ if not os.path.isfile(config_file): raise Exception("Configuration file missing") if not current_config_dict: current_config_dict = {} # Make sure these parameters will be parsed as lists. for conf_param in ['files_fetched_after_testing', \ 'pre_test_info_commands_debian', \ 'pre_test_info_commands_rpm', \ 'pre_test_info_commands']: current_config_dict[conf_param] = [] return parse_config(config_file, "conductor", current_config_dict)