Esempio n. 1
0
def test_customize(fake_run, fake_put, fake_open, fake_remote_templfile):
    env.host_string = '*****@*****.**'
    customize(add='some-disk.img', commands_from_file='commands.file')
    print(fake_remote_templfile.call_args_list)
    print(fake_put.call_args_list)
    print(fake_run.call_args_list)
    command = fake_run.call_args[0][0]
    sent_files = set(args[1]['local_path'] for args in fake_put.call_args_list)
    expected_command = ' '.join((
        "virt-customize --add some-disk.img",
        "--write /tgt/file:data",
        "--upload remote:/data.dat:/var/lib/data.dat",
        "--upload remote:/more_data.dat:/var/lib/more_data.dat",
        "--root-password random",
        "--run remote:/script.sh",
    ))
    expected_files = set(
        ('/some/data.dat', 'dir/relative/more_data.dat', '/some/script.sh'))
    assert expected_command == command
    assert expected_files == sent_files
Esempio n. 2
0
def test_customize(fake_run, fake_put, fake_open, fake_remote_templfile):
    env.host_string = "*****@*****.**"
    customize(add="some-disk.img", commands_from_file="commands.file")
    print(fake_remote_templfile.call_args_list)
    print(fake_put.call_args_list)
    print(fake_run.call_args_list)
    command = fake_run.call_args[0][0]
    sent_files = set(args[1]["local_path"] for args in fake_put.call_args_list)
    expected_command = " ".join(
        (
            "virt-customize --add some-disk.img",
            "--write /tgt/file:data",
            "--upload remote:/data.dat:/var/lib/data.dat",
            "--upload remote:/more_data.dat:/var/lib/more_data.dat",
            "--root-password random",
            "--run remote:/script.sh",
        )
    )
    expected_files = set(("/some/data.dat", "dir/relative/more_data.dat", "/some/script.sh"))
    assert expected_command == command
    assert expected_files == sent_files
Esempio n. 3
0
def test_customize_errors(abort_mockup):
    with pytest.raises(RuntimeError):
        customize()
    assert abort_mockup.called
Esempio n. 4
0
def test_customize_errors(abort_mockup):
    with pytest.raises(RuntimeError):
        customize()
    assert abort_mockup.called