def test_can_set_hiera_config_path(self, mock_run, mock_copy_dir, mock_copy_file):
class DummyGuest(Guest):
name = 'dummy'
host = Host()
guest = DummyGuest(unittest.mock.Mock())
mock_run.return_value = 0
provisioner = PuppetProvisioner('./', host, [guest], {
'manifest_file': 'site.pp',
'manifests_path': 'test_manifests',
'hiera_config_path': 'hiera.yaml'})
provisioner.provision()
assert mock_copy_file.call_count == 1
assert mock_copy_file.call_args_list[0][0][0] == Path('hiera.yaml')
assert mock_copy_file.call_args_list[0][0][1] == PurePosixPath(
provisioner._guest_hiera_file)
assert mock_run.call_count == 2
assert mock_run.call_args_list[1][0][0] == [
'sh', '-c',
"puppet apply --hiera_config={} --detailed-exitcodes --manifestdir {} {}".format(
PurePosixPath(provisioner._guest_hiera_file),
PurePosixPath(provisioner._guest_manifests_path),
PurePosixPath(provisioner._guest_manifests_path) / 'site.pp')]
评论列表
文章目录