示例#1
0
    def __init__(self, name, path, config=None):
        # type: (str, str, Config) -> None
        self._name = name
        self._path = path
        self._pup_dependencies = []  # type: List[PupDependencies]

        self._config = config or Config.get_config_singleton()
示例#2
0
    def test_initialize_config_with_config_option_values(self):
        config_options_pupfile_path = "config_pupfile.yml"

        config_options = {"pupfile_path": config_options_pupfile_path}

        Config.initialize_config_singleton(config_options=config_options)
        config = Config.get_config_singleton()

        self.assertEqual(config.get("pupfile_path"),
                         config_options_pupfile_path)
示例#3
0
    def test_initialize_config_with_config_file_values(self):
        config_file_pupfile_path = "config_pupfile.yml"
        config_file_contents = u"""
        [kennel]
        pupfile_path={}
        """.format(config_file_pupfile_path)

        Config.initialize_config_singleton(
            config_file_contents=config_file_contents)
        config = Config.get_config_singleton()

        self.assertEqual(config.get("pupfile_path"), config_file_pupfile_path)
示例#4
0
    def test_initialize_config_with_config_file_and_non_default_options(self):
        config_file_vault_password_file = "/tmp/test.txt"

        config_file_contents = u"""
        [kennel]
        vault_password_file={}
        """.format(config_file_vault_password_file)

        Config.initialize_config_singleton(
            config_file_contents=config_file_contents)
        config = Config.get_config_singleton()

        self.assertEqual(config.get("vault_password_file"),
                         config_file_vault_password_file)
示例#5
0
    def test_install(self, mock_check_call):
        ansible_dep_file_path = "/tmp/requirements.yml"

        deps = PupDependencies.create_from_dep_file_path(ansible_dep_file_path)
        deps.install()

        self.assertEqual(mock_check_call.call_count, 1)

        check_call_args, check_call_kwargs = mock_check_call.call_args
        ansible_galaxy_cmd = check_call_args[0]

        config = Config.get_config_singleton()

        expected_cmds = {
            "ansible-galaxy",
            "install",
            "-r {}".format(ansible_dep_file_path),
            "-p {}".format(config.get("abs_kennel_roles_dir")),
        }

        for cmd_line in expected_cmds:
            self.assertIn(cmd_line, ansible_galaxy_cmd)
示例#6
0
 def __init__(self, config=None):
     # type: (Config) -> None
     self._config = config or Config.get_config_singleton()
示例#7
0
    def test_initialize_config_with_calculated_config(self):
        Config.initialize_config_singleton()
        config = Config.get_config_singleton()

        for key in {"abs_pupfile_dir", "abs_kennel_roles_dir"}:
            self.assertIn("/", config.get(key))
示例#8
0
    def test_initialize_config_with_defaults(self):
        Config.initialize_config_singleton()
        config = Config.get_config_singleton()

        for default_key, default_value in iteritems(DEFAULTS):
            self.assertEqual(config.get(default_key), default_value)
示例#9
0
 def test_must_initialize_config_before_using(self):
     with self.assertRaises(SheepdogeConfigurationNotInitializedException):
         Config.get_config_singleton()
示例#10
0
 def __init__(self, additional_ansible_args="", config=None):
     # type: (str, Config) -> None
     self._additional_ansible_args = additional_ansible_args
     self._config = config or Config.get_config_singleton()
示例#11
0
    def __init__(self, dep_file_path, config=None):
        # type: (str, Config) -> None
        self._dep_file_path = dep_file_path

        self._config = config or Config.get_config_singleton()
示例#12
0
 def __init__(self, action, config=None):
     # type: (Action, Config) -> None
     self._action = action
     self._config = config or Config.get_config_singleton()