Пример #1
0
def test_proxmox_snap_without_argument(capfd):
    set_module_args({})
    with pytest.raises(SystemExit) as results:
        proxmox_snap.main()

    out, err = capfd.readouterr()
    assert not err
    assert json.loads(out)['failed']
Пример #2
0
def test_remove_snapshot_check_mode(capfd, mocker):
    set_module_args({"hostname": "test-lxc",
                     "api_user": "******",
                     "api_password": "******",
                     "api_host": "127.0.0.1",
                     "state": "absent",
                     "snapname": "test",
                     "timeout": "1",
                     "force": True,
                     "_ansible_check_mode": True})
    proxmox_snap.HAS_PROXMOXER = True
    proxmox_snap.setup_api = mocker.MagicMock(side_effect=fake_api)
    with pytest.raises(SystemExit) as results:
        proxmox_snap.main()

    out, err = capfd.readouterr()
    assert not err
    assert not json.loads(out)['changed']
Пример #3
0
def test_create_snapshot_check_mode(connect_mock, capfd, mocker):
    set_module_args({
        "hostname": "test-lxc",
        "api_user": "******",
        "api_password": "******",
        "api_host": "127.0.0.1",
        "state": "present",
        "snapname": "test",
        "timeout": "1",
        "force": True,
        "_ansible_check_mode": True
    })
    proxmox_utils.HAS_PROXMOXER = True
    connect_mock.side_effect = lambda: fake_api(mocker)
    with pytest.raises(SystemExit) as results:
        proxmox_snap.main()

    out, err = capfd.readouterr()
    assert not err
    assert not json.loads(out)['changed']