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