Beispiel #1
0
    def test_read_conductor_config_with_optional_configs(self):
        from ots.worker.conductor import conductor

        optional_value = "ps aux"
        optional_username = "******"
        conf_file = os.path.join(os.path.dirname(__file__), "conductor.conf")
        conf = conductor._read_configuration_files(conf_file, 0)
        self.assertTrue(type(conf) == type(dict()))
        self.assertTrue(conf["target_username"] != "")
        self.assertTrue(conf["device_packaging"] != "")
        self.assertTrue(conf["pre_test_info_commands_debian"] != "")
        self.assertTrue(conf["pre_test_info_commands_rpm"] != "")
        self.assertTrue(conf["pre_test_info_commands"] != "")
        self.assertTrue(conf["files_fetched_after_testing"] != "")
        self.assertTrue(conf["tmp_path"] != "")

        # Check that we do not have value in pre_test_info_commands that we will
        # insert from optional configuration file
        self.assertFalse(optional_value in conf["pre_test_info_commands"])

        temp_folder = tempfile.mkdtemp("_optional_confs")
        temp_config = tempfile.mktemp(suffix=".conf", dir=temp_folder)
        fp = open(temp_config, "w")
        fp.write(
            "[conductor]\n" 'pre_test_info_commands: "%s"\n' "target_username: %s" % (optional_value, optional_username)
        )
        fp.close()

        conf["custom_config_folder"] = temp_folder
        conf = conductor._read_optional_config_files(temp_folder, conf)
        self.assertTrue(optional_value in conf["pre_test_info_commands"])
        self.assertTrue(conf["target_username"] == optional_username)

        os.unlink(temp_config)
        os.rmdir(temp_folder)
Beispiel #2
0
 def test_read_conductor_config(self):
     from ots.worker.conductor import conductor
     conf_file = os.path.join(os.path.dirname(__file__), "conductor.conf")
     conf = conductor._read_configuration_files(conf_file, 0)
     self.assertTrue(type(conf) == type(dict()))
     self.assertTrue(conf['target_username'] != "")
     self.assertTrue(conf['device_packaging'] != "")
     self.assertTrue(conf['pre_test_info_commands_debian'] != "")
     self.assertTrue(conf['pre_test_info_commands_rpm'] != "")
     self.assertTrue(conf['pre_test_info_commands'] != "")
     self.assertTrue(conf['files_fetched_after_testing'] != "")
     self.assertTrue(conf['tmp_path'] != "")
Beispiel #3
0
    def test_read_conductor_config(self):
        from ots.worker.conductor import conductor

        conf_file = os.path.join(os.path.dirname(__file__), "conductor.conf")
        conf = conductor._read_configuration_files(conf_file, 0)
        self.assertTrue(type(conf) == type(dict()))
        self.assertTrue(conf["target_username"] != "")
        self.assertTrue(conf["device_packaging"] != "")
        self.assertTrue(conf["pre_test_info_commands_debian"] != "")
        self.assertTrue(conf["pre_test_info_commands_rpm"] != "")
        self.assertTrue(conf["pre_test_info_commands"] != "")
        self.assertTrue(conf["files_fetched_after_testing"] != "")
        self.assertTrue(conf["tmp_path"] != "")
Beispiel #4
0
    def test_read_conductor_config_with_optional_configs(self):
        from ots.worker.conductor import conductor
        optional_value = "ps aux"
        optional_username = "******"
        conf_file = os.path.join(os.path.dirname(__file__), "conductor.conf")
        conf = conductor._read_configuration_files(conf_file, 0)
        self.assertTrue(type(conf) == type(dict()))
        self.assertTrue(conf['target_username'] != "")
        self.assertTrue(conf['device_packaging'] != "")
        self.assertTrue(conf['pre_test_info_commands_debian'] != "")
        self.assertTrue(conf['pre_test_info_commands_rpm'] != "")
        self.assertTrue(conf['pre_test_info_commands'] != "")
        self.assertTrue(conf['files_fetched_after_testing'] != "")
        self.assertTrue(conf['tmp_path'] != "")

        # Check that we do not have value in pre_test_info_commands that we will
        # insert from optional configuration file
        self.assertFalse(optional_value in conf['pre_test_info_commands'])

        temp_folder = tempfile.mkdtemp("_optional_confs")
        temp_config = tempfile.mktemp(suffix='.conf', dir=temp_folder)
        fp = open(temp_config, 'w')
        fp.write('[conductor]\n'\
                 'pre_test_info_commands: "%s"\n'\
                 'target_username: %s' % (
                optional_value,
                optional_username))
        fp.close()

        conf['custom_config_folder'] = temp_folder
        conf = conductor._read_optional_config_files(temp_folder, conf)
        self.assertTrue(optional_value in conf['pre_test_info_commands'])
        self.assertTrue(conf['target_username'] == optional_username)

        os.unlink(temp_config)
        os.rmdir(temp_folder)