uitests: Add host*.py coverage

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-08-21 14:39:24 -04:00
parent 6f8c305d62
commit 9a9eb165ed
10 changed files with 147 additions and 24 deletions

View File

@ -1731,8 +1731,8 @@ ba</description>
</volume>
<volume type='file'>
<name>UPPER</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<capacity>10000000</capacity>
<allocation>500000</allocation>
<target>
<permissions>
<mode>0700</mode>
@ -1786,8 +1786,8 @@ ba</description>
</volume>
<volume type='file'>
<name>backingl1.img</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<capacity>100000</capacity>
<allocation>5000</allocation>
<target>
<format type='qcow2'/>
</target>

View File

@ -51,10 +51,12 @@ class CreateNet(uiutils.UITestCase):
stop.click()
uiutils.check_in_loop(lambda: delete.sensitive)
# Delete it
# Delete it, clicking No first
delete.click()
self._click_alert_button("permanently delete the network", "No")
uiutils.check_in_loop(lambda: not cell.dead)
delete.click()
self._click_alert_button("permanently delete the network", "Yes")
# Ensure it's gone
uiutils.check_in_loop(lambda: cell.dead)

View File

@ -59,10 +59,12 @@ class CreatePool(uiutils.UITestCase):
stop.click()
uiutils.check_in_loop(lambda: delete.sensitive)
# Delete it
# Delete it, clicking 'No' first
delete.click()
self._click_alert_button("permanently delete the pool", "No")
uiutils.check_in_loop(lambda: not cell.dead)
delete.click()
self._click_alert_button("permanently delete the pool", "Yes")
# Ensure it's gone
uiutils.check_in_loop(lambda: cell.dead)

View File

@ -76,8 +76,17 @@ class CreateVol(uiutils.UITestCase):
combo.find("qcow2", "menu item").click()
win.find("Backing store").click_expander()
win.find("Browse...").click()
browsewin = self.app.root.find(
"Choose Storage Volume", "frame")
browsewin = self.app.root.find("Choose Storage Volume", "frame")
# Test cancel button
browsewin.find("Cancel", "push button").click()
uiutils.check_in_loop(lambda: not browsewin.active)
win.find("Browse...").click()
browsewin = self.app.root.find("Choose Storage Volume", "frame")
# Test browse local opening
browsewin.find("Browse Local", "push button").click()
chooser = self.app.root.find(
"Locate existing storage", "file chooser")
chooser.keyCombo("<alt>F4")
browsewin.find_fuzzy("default-pool", "table cell").click()
browsewin.find("bochs-vol", "table cell").doubleClick()
uiutils.check_in_loop(lambda: not browsewin.active)
@ -124,7 +133,8 @@ class CreateVol(uiutils.UITestCase):
browsewin = self.app.root.find(
"Choose Storage Volume", "frame")
browsewin.find_fuzzy("disk-pool", "table cell").click()
browsewin.find("diskvol7", "table cell").doubleClick()
browsewin.find("diskvol7", "table cell").click()
browsewin.find("Choose Volume").click()
finish.click()
vollist.find(newname)

View File

@ -34,7 +34,7 @@ class Host(uiutils.UITestCase):
win = self._open_host_window("Virtual Networks").find("network-grid")
finish = win.find("Apply", "push button")
# Shut off a pool, do an XML edit, verify it
# Shut it off, do an XML edit, verify it
win.find("default", "table cell").click()
delete = win.find("net-delete", "push button")
stop = win.find("net-stop", "push button")
@ -49,6 +49,17 @@ class Host(uiutils.UITestCase):
win.find("Details", "page tab").click()
self.assertEqual(win.find("net-device").text, newdev)
# Rename it
win.find("default", "table cell").click()
win.find("net-name").text = "newsort-default"
finish.click()
# Change autostart, trigger it by clicking away
win.find("newsort-default", "table cell").click()
win.find("net-autostart").click()
win.find("netboot", "table cell").click()
self._click_alert_button("There are unapplied changes", "Yes")
# Do standard xmleditor tests
self._test_xmleditor_interactions(win, finish)
@ -89,5 +100,83 @@ class Host(uiutils.UITestCase):
win.find("Details", "page tab").click()
self.assertEqual(win.find("pool-location").text, newpath)
# Rename it
win.find("default", "table cell").click()
win.find("pool-name").text = "newsort-default"
finish.click()
# Change autostart. Trigger it by clicking on new cell
win.find("newsort-default", "table cell").click()
win.find("pool-autostart").click()
win.find("disk-pool", "table cell").click()
self._click_alert_button("There are unapplied changes", "Yes")
# Do standard xmleditor tests
self._test_xmleditor_interactions(win, finish)
def testHostStorageVolMisc(self):
"""
Misc actions involving volumes
"""
win = self._open_host_window("Storage").find("storage-grid")
win.find_fuzzy("default-pool", "table cell").click()
vollist = win.find("vol-list", "table")
vol1 = vollist.find("backingl1.img", "table cell")
vol2 = vollist.find("UPPER", "table cell")
assert vol1.onscreen
assert not vol2.onscreen
win.find("Size", "table column header").click()
win.find("Size", "table column header").click()
uiutils.check_in_loop(lambda: not vol1.onscreen)
assert vol2.onscreen
vol2.click(button=3)
self.app.root.find("Copy Volume Path", "menu item").click()
from gi.repository import Gdk, Gtk
clipboard = Gtk.Clipboard.get_default(Gdk.Display.get_default())
assert clipboard.wait_for_text() == "/dev/default-pool/UPPER"
def testHostConn(self):
"""
Change some connection parameters
"""
manager = self.app.topwin
# Disconnect the connection
c = manager.find_fuzzy("testdriver.xml", "table cell")
c.click(button=3)
self.app.root.find("conn-disconnect", "menu item").click()
uiutils.check_in_loop(lambda: "Not Connected" in c.text)
# Open Host Details from right click menu
c.click(button=3)
self.app.root.find("conn-details", "menu item").click()
win = self.app.root.find_fuzzy("Connection Details", "frame")
# Click the tabs and then back
win.find_fuzzy("Storage", "tab").click()
win.find_fuzzy("Network", "tab").click()
win.find_fuzzy("Overview", "tab").click()
# Unset autoconnect
win.find("Autoconnect:", "check box").click()
# Change the name, verify that title bar changed
win.find("Name:", "text").text = "FOOBAR"
self.app.root.find("FOOBAR Connection Details", "frame")
# Open the manager window
win.find("File", "menu").click()
win.find("View Manager", "menu item").click()
uiutils.check_in_loop(lambda: manager.active)
# Confirm connection row is named differently in manager
manager.find("FOOBAR", "table cell")
# Close the manager
manager.keyCombo("<alt>F4")
uiutils.check_in_loop(lambda: win.active)
# Quit app from the file menu
win.find("File", "menu").click()
win.find("Quit", "menu item").click()
uiutils.check_in_loop(lambda: not self.app.is_running())

View File

@ -113,6 +113,11 @@
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_net_autostart_toggled" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="net-autostart-atkobject">
<property name="AtkObject::accessible-name">net-autostart</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
@ -217,6 +222,11 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_net_name_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="net-name-atkobject">
<property name="AtkObject::accessible-name">net-name</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkImage" id="image3">
@ -331,6 +331,11 @@
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_pool_autostart_toggled" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="pool-autostart-atkobject">
<property name="AtkObject::accessible-name">pool-autostart</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
@ -360,6 +365,11 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_pool_name_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="pool-name-entry-atkobject">
<property name="AtkObject::accessible-name">pool-name</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>

View File

@ -25,7 +25,7 @@ class vmmHost(vmmGObjectUI):
if uri not in cls._instances:
cls._instances[uri] = vmmHost(conn)
cls._instances[uri].show()
except Exception as e:
except Exception as e: # pragma: no cover
if not parentobj:
raise
parentobj.err.show_err(
@ -88,7 +88,7 @@ class vmmHost(vmmGObjectUI):
vis = self.is_visible()
self.topwin.present()
if vis:
return
return # pragma: no cover
vmmEngine.get_instance().increment_window_counter()

View File

@ -136,7 +136,7 @@ class vmmHostNets(vmmGObjectUI):
self.conn.support.conn_network())
if conn_active and not self.conn.support.conn_network():
self._set_error_page(
self._set_error_page( # pragma: no cover
_("Libvirt connection does not support virtual network "
"management."))

View File

@ -148,7 +148,7 @@ class vmmHostStorage(vmmGObjectUI):
# UI init #
###########
def _cap_sort_func_cb(self, model, iter1, iter2):
def _cap_sort_func_cb(self, model, iter1, iter2, userdata):
def _cmp(a, b):
return ((a > b) - (a < b))
@ -511,7 +511,7 @@ class vmmHostStorage(vmmGObjectUI):
def _pool_refresh_cb(self, src):
pool = self._current_pool()
if pool is None:
return
return # pragma: no cover
self._confirm_changes()
@ -527,7 +527,7 @@ class vmmHostStorage(vmmGObjectUI):
def _vol_copy_path_cb(self, src):
vol = self._current_vol()
if not vol:
return
return # pragma: no cover
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
target_path = vol.get_target_path()
@ -537,7 +537,7 @@ class vmmHostStorage(vmmGObjectUI):
def _vol_add_cb(self, src):
pool = self._current_pool()
if pool is None:
return
return # pragma: no cover
log.debug("Launching 'Add Volume' wizard for pool '%s'",
pool.get_name())
@ -550,13 +550,13 @@ class vmmHostStorage(vmmGObjectUI):
self._addvol.set_modal(self.topwin.get_modal())
self._addvol.set_name_hint(self._name_hint)
self._addvol.show(self.topwin)
except Exception as e:
except Exception as e: # pragma: no cover
self.err.show_err(_("Error launching volume wizard: %s") % str(e))
def _vol_delete_cb(self, src):
vol = self._current_vol()
if vol is None:
return
return # pragma: no cover
pool = self._current_pool()
result = self.err.yes_no(_("Are you sure you want to permanently "
@ -582,7 +582,7 @@ class vmmHostStorage(vmmGObjectUI):
def _pool_apply(self):
pool = self._current_pool()
if pool is None:
return
return # pragma: no cover
log.debug("Applying changes for pool '%s'", pool.get_name())
try:
@ -641,7 +641,7 @@ class vmmHostStorage(vmmGObjectUI):
# select the vol we just created.
pool = self._current_pool()
if not pool or pool.get_connkey() != pool_connkey:
return
return # pragma: no cover
# Select the new volume
uiutil.set_list_selection(self.widget("vol-list"), volname)