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()
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)
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)
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)
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)
def __init__(self, config=None): # type: (Config) -> None self._config = config or Config.get_config_singleton()
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))
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)
def test_must_initialize_config_before_using(self): with self.assertRaises(SheepdogeConfigurationNotInitializedException): Config.get_config_singleton()
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()
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()
def __init__(self, action, config=None): # type: (Action, Config) -> None self._action = action self._config = config or Config.get_config_singleton()