mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
virtManager: Misc coverage annotations
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
@@ -12,7 +12,7 @@ from gi.repository import Gtk
|
||||
BASECOLOR = Gtk.StyleContext().lookup_color("theme_base_color")[1]
|
||||
|
||||
|
||||
def rect_print(name, rect):
|
||||
def rect_print(name, rect): # pragma: no cover
|
||||
# For debugging
|
||||
print("%s: height=%d, width=%d, x=%d, y=%d" %
|
||||
(name, rect.height, rect.width, rect.x, rect.y))
|
||||
@@ -53,7 +53,7 @@ def _line_helper(cairo_ct, bottom_baseline, points, for_fill=False):
|
||||
|
||||
def draw_line(cairo_ct, y, h, points):
|
||||
if not len(points):
|
||||
return
|
||||
return # pragma: no cover
|
||||
|
||||
last_point = _line_helper(cairo_ct, y + h, points)
|
||||
if not last_point:
|
||||
@@ -66,7 +66,7 @@ def draw_line(cairo_ct, y, h, points):
|
||||
|
||||
def draw_fill(cairo_ct, x, y, w, h, points, taper=False):
|
||||
if not len(points):
|
||||
return
|
||||
return # pragma: no cover
|
||||
|
||||
_line_helper(cairo_ct, y + h, points, for_fill=True)
|
||||
|
||||
@@ -175,10 +175,9 @@ class CellRendererSparkline(Gtk.CellRenderer):
|
||||
def get_y(index):
|
||||
baseline_y = graph_y + graph_height
|
||||
|
||||
n = index
|
||||
if self.reversed:
|
||||
n = (len(self.data_array) - index - 1)
|
||||
else:
|
||||
n = index
|
||||
|
||||
val = self.data_array[n]
|
||||
y = baseline_y - (graph_height * val)
|
||||
@@ -216,19 +215,14 @@ class CellRendererSparkline(Gtk.CellRenderer):
|
||||
|
||||
def do_get_size(self, widget, cell_area=None):
|
||||
ignore = widget
|
||||
ignore = cell_area
|
||||
|
||||
FIXED_WIDTH = len(self.data_array)
|
||||
FIXED_HEIGHT = 15
|
||||
xpad = self.get_property("xpad")
|
||||
ypad = self.get_property("ypad")
|
||||
|
||||
if cell_area:
|
||||
# What to do here? haven't encountered this in practice
|
||||
xoffset = 0
|
||||
yoffset = 0
|
||||
else:
|
||||
xoffset = 0
|
||||
yoffset = 0
|
||||
xoffset = 0
|
||||
yoffset = 0
|
||||
|
||||
width = ((xpad * 2) + FIXED_WIDTH)
|
||||
height = ((ypad * 2) + FIXED_HEIGHT)
|
||||
@@ -239,7 +233,7 @@ class CellRendererSparkline(Gtk.CellRenderer):
|
||||
# variables can't be named like that
|
||||
def _sanitize_param_spec_name(self, name):
|
||||
return name.replace("-", "_")
|
||||
def do_get_property(self, param_spec):
|
||||
def do_get_property(self, param_spec): # pragma: no cover
|
||||
name = self._sanitize_param_spec_name(param_spec.name)
|
||||
return getattr(self, name)
|
||||
def do_set_property(self, param_spec, value):
|
||||
@@ -365,7 +359,7 @@ class Sparkline(Gtk.DrawingArea):
|
||||
|
||||
return 0
|
||||
|
||||
def do_size_request(self, requisition):
|
||||
def do_size_request(self, requisition): # pragma: no cover
|
||||
width = len(self.data_array) / self.num_sets
|
||||
height = 20
|
||||
|
||||
@@ -376,7 +370,7 @@ class Sparkline(Gtk.DrawingArea):
|
||||
# variables can't be named like that
|
||||
def _sanitize_param_spec_name(self, name):
|
||||
return name.replace("-", "_")
|
||||
def do_get_property(self, param_spec):
|
||||
def do_get_property(self, param_spec): # pragma: no cover
|
||||
name = self._sanitize_param_spec_name(param_spec.name)
|
||||
return getattr(self, name)
|
||||
def do_set_property(self, param_spec, value):
|
||||
|
||||
@@ -10,10 +10,6 @@ import libvirt
|
||||
from virtinst import log
|
||||
|
||||
|
||||
if not hasattr(libvirt, "VIR_DOMAIN_PMSUSPENDED"):
|
||||
setattr(libvirt, "VIR_DOMAIN_PMSUSPENDED", 7)
|
||||
|
||||
|
||||
class _LibvirtEnumMap(object):
|
||||
"""
|
||||
Helper for mapping libvirt event int values to their API names
|
||||
@@ -74,7 +70,7 @@ class _LibvirtEnumMap(object):
|
||||
elif status == libvirt.VIR_DOMAIN_PAUSED:
|
||||
return _("Paused")
|
||||
elif status == libvirt.VIR_DOMAIN_SHUTDOWN:
|
||||
return _("Shutting Down")
|
||||
return _("Shutting Down") # pragma: no cover
|
||||
elif status == libvirt.VIR_DOMAIN_SHUTOFF:
|
||||
if has_managed_save:
|
||||
return _("Saved")
|
||||
@@ -85,8 +81,9 @@ class _LibvirtEnumMap(object):
|
||||
elif status == libvirt.VIR_DOMAIN_PMSUSPENDED:
|
||||
return _("Suspended")
|
||||
|
||||
log.debug("Unknown status %s, returning 'Unknown'", status)
|
||||
return _("Unknown")
|
||||
log.debug( # pragma: no cover
|
||||
"Unknown status %s, returning 'Unknown'", status)
|
||||
return _("Unknown") # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def pretty_status_reason(status, reason):
|
||||
@@ -142,11 +139,11 @@ class _LibvirtEnumMap(object):
|
||||
ret = {}
|
||||
for key in [a for a in dir(libvirt) if re.match(regex, a)]:
|
||||
val = getattr(libvirt, key)
|
||||
if type(val) is not int:
|
||||
if type(val) is not int: # pragma: no cover
|
||||
log.debug("libvirt regex=%s key=%s val=%s "
|
||||
"isn't an integer", regex, key, val)
|
||||
continue
|
||||
if val in ret:
|
||||
if val in ret: # pragma: no cover
|
||||
log.debug("libvirt regex=%s key=%s val=%s is already "
|
||||
"in dict as key=%s", regex, key, val, regex[val])
|
||||
continue
|
||||
@@ -168,7 +165,7 @@ class _LibvirtEnumMap(object):
|
||||
|
||||
if eventmap:
|
||||
if event not in eventmap:
|
||||
event = next(iter(eventmap))
|
||||
event = next(iter(eventmap)) # pragma: no cover
|
||||
eventstr = eventmap[event]
|
||||
detail1map = self._get_map(eventstr,
|
||||
self._DETAIL1_PREFIX.get(eventstr))
|
||||
|
||||
Reference in New Issue
Block a user