2020-08-26 20:46:25 +08:00
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
|
|
|
# See the COPYING file in the top-level directory.
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2020-09-12 01:02:51 +08:00
|
|
|
from . import lib
|
2020-08-26 20:46:25 +08:00
|
|
|
|
|
|
|
try:
|
|
|
|
import guestfs
|
|
|
|
ignore = guestfs
|
|
|
|
HAS_LIBGUESTFS = True
|
|
|
|
except Exception:
|
|
|
|
HAS_LIBGUESTFS = False
|
|
|
|
|
|
|
|
|
2020-09-19 05:27:50 +08:00
|
|
|
#########################################################
|
|
|
|
# UI tests for the libguestfs inspection infrastructure #
|
|
|
|
#########################################################
|
|
|
|
|
|
|
|
def testInspectionMock(app):
|
|
|
|
if not HAS_LIBGUESTFS:
|
|
|
|
pytest.skip("libguestfs python not installed")
|
|
|
|
|
|
|
|
# Use the test suite inspection mocking to test parts
|
|
|
|
# of the UI that interact with inspection data
|
|
|
|
app.open(enable_libguestfs=True)
|
|
|
|
manager = app.topwin
|
|
|
|
|
|
|
|
details = app.manager_open_details("test-clone")
|
|
|
|
details.find("OS information", "table cell").click()
|
|
|
|
tab = details.find("os-tab")
|
|
|
|
|
|
|
|
tab.find("Application", "toggle").click_expander()
|
|
|
|
apps = tab.find("inspection-apps")
|
|
|
|
apps.check_onscreen()
|
|
|
|
apps.click_expander()
|
|
|
|
|
|
|
|
nodestr1 = apps.fmt_nodes()
|
|
|
|
assert "test_app1_summary" in nodestr1
|
|
|
|
tab.find("Refresh", "push button").click()
|
|
|
|
lib.utils.check(lambda: apps.fmt_nodes() != nodestr1)
|
|
|
|
|
2020-09-20 22:07:15 +08:00
|
|
|
details.window_close()
|
2020-09-19 05:27:50 +08:00
|
|
|
|
|
|
|
# Open a VM with no disks which will report an inspection error
|
|
|
|
app.root.find_fuzzy("test\n", "table cell").doubleClick()
|
|
|
|
details = app.find_window("test on")
|
|
|
|
details.find("Details", "radio button").click()
|
|
|
|
details.find("OS information", "table cell").click()
|
|
|
|
tab = details.find("os-tab")
|
|
|
|
tab.find_fuzzy("Fake test error no disks")
|
|
|
|
|
|
|
|
# Closing and reopening a connection triggers some libguest
|
|
|
|
# cache reading
|
2020-09-20 22:07:15 +08:00
|
|
|
details.window_close()
|
2020-09-19 05:27:50 +08:00
|
|
|
manager.click()
|
2020-09-20 22:07:15 +08:00
|
|
|
c = manager.find("test testdriver.xml", "table cell")
|
2020-09-19 05:27:50 +08:00
|
|
|
app.manager_conn_disconnect("test testdriver.xml")
|
2020-09-20 22:07:15 +08:00
|
|
|
lib.utils.check(lambda: "Not Connected" in c.text)
|
2020-09-19 05:27:50 +08:00
|
|
|
app.manager_conn_connect("test testdriver.xml")
|
2020-09-20 22:07:15 +08:00
|
|
|
lib.utils.check(lambda: "Not Connected" not in c.text)
|