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")
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)
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")
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
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
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