Пример #1
0
def test_not_exists_or_throws_throws_for_unexpected_exit_code():
    # returncode 2 is "domain not found"
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(237687263),
               autospec=True):
        with pytest.raises(lib.QsmProcessError):
            dom0.exists("fedora-template")
Пример #2
0
def test_create_exists_ok_throws_when_unexpected_exit_code():
    # run should exit(2) when vm doesn't exist, so any exit code other than that
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(273863),
               autospec=True):
        with pytest.raises(lib.QsmProcessError):
            dom0.create("fedora-template", "red", exists_ok=True)
Пример #3
0
def test_is_stopped_or_throws_throws_for_unexpected_exit_code():
    # returncode 1 is "domain is running"
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(7612736),
               autospec=True):
        with pytest.raises(lib.QsmProcessError):
            dom0.is_stopped_or_throws("fedora-template")
Пример #4
0
def test__is_template__false():
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(1),
               autospec=True):
        assert dom0.is_template("test-template") is False
Пример #5
0
def test_exists_returns_false_when_vm_doesnt_exist():
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(QVM_CHECK_EXISTS_NOT_FOUND),
               autospec=True):
        assert dom0.exists("fedora-template") is False
Пример #6
0
def test_is_running_returns_false_when_vm_isnt_running():
    with patch("qsm.dom0.lib.run",
               side_effect=lib.QsmProcessError(QVM_CHECK_IS_NOT_RUNNING),
               autospec=True):
        assert dom0.is_running("fedora-template") is False