summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2022-01-17 16:07:25 -0500
committerCole Robinson <crobinso@redhat.com>2022-01-17 17:11:18 -0500
commitacaca061be183957c4e2f99397f17711060401eb (patch)
treebf06d19682f100f9d319a3ef3f9009425ccaa1ec
parent4f02ccd7b5e61fea693ce6e6e2ffd1b1c2f23654 (diff)
downloadvirt-manager-acaca061be183957c4e2f99397f17711060401eb.tar.gz
uitests: top off test coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r--tests/uitests/test_createvm.py2
-rw-r--r--tests/uitests/test_details.py4
-rw-r--r--virtManager/details/details.py16
-rw-r--r--virtManager/lib/statsmanager.py5
-rw-r--r--virtManager/lib/testmock.py12
-rw-r--r--virtManager/object/nodedev.py4
6 files changed, 22 insertions, 21 deletions
diff --git a/tests/uitests/test_createvm.py b/tests/uitests/test_createvm.py
index d51ccc32..60d6d8ca 100644
--- a/tests/uitests/test_createvm.py
+++ b/tests/uitests/test_createvm.py
@@ -3,8 +3,6 @@
import unittest.mock
-import pytest
-
import tests
from . import lib
diff --git a/tests/uitests/test_details.py b/tests/uitests/test_details.py
index c8d6fe6c..8ed44bd9 100644
--- a/tests/uitests/test_details.py
+++ b/tests/uitests/test_details.py
@@ -89,7 +89,8 @@ def _testRename(app, win, origname, newname):
app.root.find_fuzzy(newname, "table cell")
# Make sure the old entry is gone
- lib.utils.check(lambda: origname not in oldcell.name)
+ if origname != newname:
+ lib.utils.check(lambda: origname not in oldcell.name)
def testDetailsRenameSimple(app):
@@ -98,6 +99,7 @@ def testDetailsRenameSimple(app):
"""
origname = "test-clone-simple"
win = app.manager_open_details(origname)
+ _testRename(app, win, origname, origname)
_testRename(app, win, origname, "test-new-name")
diff --git a/virtManager/details/details.py b/virtManager/details/details.py
index 27f2ecb7..aedd2ca7 100644
--- a/virtManager/details/details.py
+++ b/virtManager/details/details.py
@@ -318,26 +318,18 @@ def _get_performance_icon_name():
def _unindent_device_xml(xml):
- """
- The device parsed from a domain will have no indent
- for the first line, but then <domain> expected indent
- from the remaining lines. Try to unindent the remaining
- lines so it looks nice in the XML editor.
- """
lines = xml.splitlines()
- if not xml.startswith("<") or len(lines) < 2:
- return xml
+ if not lines:
+ return xml # pragma: no cover
ret = ""
unindent = 0
- for c in lines[1]:
+ for c in lines[0]:
if c != " ":
break
unindent += 1
- unindent = max(0, unindent - 2)
- ret = lines[0] + "\n"
- for line in lines[1:]:
+ for line in lines:
if re.match(r"^%s *<.*$" % (unindent * " "), line):
line = line[unindent:]
ret += line + "\n"
diff --git a/virtManager/lib/statsmanager.py b/virtManager/lib/statsmanager.py
index d19129f3..28495495 100644
--- a/virtManager/lib/statsmanager.py
+++ b/virtManager/lib/statsmanager.py
@@ -128,7 +128,6 @@ class vmmStatsManager(vmmGObject):
self._disk_stats_lxc_supported = True
self._mem_stats_supported = True
-
def _cleanup(self):
for statslist in self._vm_stats.values():
statslist.cleanup()
@@ -390,7 +389,9 @@ class vmmStatsManager(vmmGObject):
####################
def _get_all_stats(self, conn):
- if not self._all_stats_supported:
+ # test conn supports allstats as of 2021, but for test coverage
+ # purposes lets still use the old stats code for the test driver
+ if not self._all_stats_supported or conn.is_test():
return {}
statflags = 0
diff --git a/virtManager/lib/testmock.py b/virtManager/lib/testmock.py
index 3234fcae..1f3e91ac 100644
--- a/virtManager/lib/testmock.py
+++ b/virtManager/lib/testmock.py
@@ -107,9 +107,19 @@ def fake_openauth(conn, cb, data):
class fakeVirtBootstrap:
+ @staticmethod
def bootstrap(**kwargs):
import time
- time.sleep(1)
+ import logging
+ log = logging.getLogger("virtBootstrap")
+ log.info("mock virtBootstrap msg1")
+ kwargs["progress_cb"]({"status": "msg1"})
+ time.sleep(.5)
+ log.info("mock virtBootstrap msg2")
+ kwargs["progress_cb"]({"status": "msg2"})
+ time.sleep(.5)
+ log.info("mock virtBootstrap msg3")
+ kwargs["progress_cb"]({"status": "msg3"})
if "username" in kwargs:
raise RuntimeError("fakeVirtBootstrap mock auth failure!")
diff --git a/virtManager/object/nodedev.py b/virtManager/object/nodedev.py
index a89663fb..982956d9 100644
--- a/virtManager/object/nodedev.py
+++ b/virtManager/object/nodedev.py
@@ -53,14 +53,12 @@ class vmmNodeDevice(vmmLibvirtObject):
def _XMLDesc(self, flags):
return self._backend.XMLDesc(flags)
- def _get_backend_status(self):
- return self._STATUS_ACTIVE
def _using_events(self):
return self.conn.using_node_device_events
def _get_backend_status(self):
is_active = True
if self.conn.support.nodedev_isactive(self._backend):
- is_active = self._backend.isActive()
+ is_active = self._backend.isActive() # pragma: no cover
return (is_active and
self._STATUS_ACTIVE or
self._STATUS_INACTIVE)