uitests: Finish createconn.py coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
35d4687237
commit
fd5216c184
|
@ -36,23 +36,57 @@ class VMMConnect(uiutils.UITestCase):
|
|||
host = win.find("Hostname", "text")
|
||||
urilabel = win.find("uri-label", "label")
|
||||
urientry = win.find("uri-entry", "text")
|
||||
self.assertTrue(user.showing is host.showing is True)
|
||||
assert user.showing is host.showing is True
|
||||
|
||||
# Select all HV options
|
||||
hvcombo = win.find_fuzzy("Hypervisor", "combo box")
|
||||
def _click_hv(hvname):
|
||||
hvcombo.click()
|
||||
hvcombo.find_fuzzy(hvname, "menu item").click()
|
||||
_click_hv("user session")
|
||||
_click_hv("QEMU/KVM")
|
||||
_click_hv("Xen")
|
||||
_click_hv("Bhyve")
|
||||
_click_hv("Virtuozzo")
|
||||
_click_hv("LXC")
|
||||
|
||||
# Test a simple selection
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("QEMU/KVM user session", "menu item").click()
|
||||
self.assertTrue(user.showing is host.showing is False)
|
||||
self.assertTrue(urilabel.text == "qemu:///session")
|
||||
assert user.showing is host.showing is False
|
||||
assert urilabel.text == "qemu:///session"
|
||||
|
||||
# Cancel the dialog
|
||||
win.find_fuzzy("Cancel", "push button").click()
|
||||
uiutils.check_in_loop(lambda: not win.showing)
|
||||
|
||||
# Reopen it, confirm content changed
|
||||
self.app.root.find("File", "menu").click()
|
||||
self.app.root.find("Add Connection...", "menu item").click()
|
||||
win = self.app.root.find_fuzzy("Add Connection", "dialog")
|
||||
assert ":///session" not in urilabel.text
|
||||
|
||||
# Relaunch the dialog, confirm it doesn't overwrite content
|
||||
_click_hv("LXC")
|
||||
uiutils.check_in_loop(lambda: "lxc" in urilabel.text)
|
||||
self.app.root.find("File", "menu").click()
|
||||
self.app.root.find("Add Connection...", "menu item").click()
|
||||
uiutils.check_in_loop(lambda: win.active)
|
||||
uiutils.check_in_loop(lambda: "lxc" in urilabel.text)
|
||||
|
||||
# Enter a failing URI, make sure error is raised, and we can
|
||||
# fall back to the dialog
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("Xen", "menu item").click()
|
||||
_click_hv("Xen")
|
||||
remote.click()
|
||||
user.text = "fribuser"
|
||||
connect.click()
|
||||
self._click_alert_button("hostname is required", "OK")
|
||||
fakeipv6 = "fe80::1"
|
||||
host.text = fakeipv6
|
||||
assert urilabel.text == "xen+ssh://fribuser@[%s]/" % fakeipv6
|
||||
fakehost = "ix8khfyidontexistkdjur.com"
|
||||
host.text = fakehost + ":12345"
|
||||
self.assertTrue(
|
||||
urilabel.text == "xen+ssh://fribuser@%s:12345/" % fakehost)
|
||||
assert urilabel.text == "xen+ssh://fribuser@%s:12345/" % fakehost
|
||||
connect.click()
|
||||
|
||||
uiutils.check_in_loop(lambda: win.showing is True)
|
||||
|
@ -63,7 +97,7 @@ class VMMConnect(uiutils.UITestCase):
|
|||
|
||||
# Ensure dialog shows old contents for editing
|
||||
uiutils.check_in_loop(lambda: win.showing)
|
||||
self.assertTrue(fakehost in host.text)
|
||||
assert fakehost in host.text
|
||||
|
||||
# This time say 'yes'
|
||||
connect.click()
|
||||
|
@ -79,8 +113,16 @@ class VMMConnect(uiutils.UITestCase):
|
|||
self.app.root.find("File", "menu").click()
|
||||
self.app.root.find("Add Connection...", "menu item").click()
|
||||
win = self.app.root.find_fuzzy("Add Connection", "dialog")
|
||||
win.find_fuzzy("Hypervisor", "combo box").click()
|
||||
win.find_fuzzy("Custom URI", "menu item").click()
|
||||
_click_hv("Custom URI")
|
||||
urientry.text = "test:///default"
|
||||
connect.click()
|
||||
|
||||
# Do it again to make sure things don't explode
|
||||
uiutils.check_in_loop(lambda: win.showing is False)
|
||||
self.app.root.find("File", "menu").click()
|
||||
self.app.root.find("Add Connection...", "menu item").click()
|
||||
win = self.app.root.find_fuzzy("Add Connection", "dialog")
|
||||
_click_hv("Custom URI")
|
||||
urientry.text = "test:///default"
|
||||
connect.click()
|
||||
|
|
@ -25,6 +25,25 @@ HV_VZ,
|
|||
HV_CUSTOM) = range(7)
|
||||
|
||||
|
||||
def _default_uri(): # pragma: no cover
|
||||
if os.path.exists('/var/lib/xen'):
|
||||
if (os.path.exists('/dev/xen/evtchn') or
|
||||
os.path.exists("/proc/xen")):
|
||||
return 'xen:///'
|
||||
|
||||
if (os.path.exists("/usr/bin/qemu") or
|
||||
os.path.exists("/usr/bin/qemu-kvm") or
|
||||
os.path.exists("/usr/bin/kvm") or
|
||||
os.path.exists("/usr/libexec/qemu-kvm") or
|
||||
glob.glob("/usr/bin/qemu-system-*")):
|
||||
return "qemu:///system"
|
||||
|
||||
if (os.path.exists("/usr/lib/libvirt/libvirt_lxc") or
|
||||
os.path.exists("/usr/lib64/libvirt/libvirt_lxc")):
|
||||
return "lxc:///"
|
||||
return None
|
||||
|
||||
|
||||
class vmmCreateConn(vmmGObjectUI):
|
||||
@classmethod
|
||||
def get_instance(cls, parentobj):
|
||||
|
@ -56,22 +75,7 @@ class vmmCreateConn(vmmGObjectUI):
|
|||
|
||||
@staticmethod
|
||||
def default_uri():
|
||||
if os.path.exists('/var/lib/xen'):
|
||||
if (os.path.exists('/dev/xen/evtchn') or
|
||||
os.path.exists("/proc/xen")):
|
||||
return 'xen:///'
|
||||
|
||||
if (os.path.exists("/usr/bin/qemu") or
|
||||
os.path.exists("/usr/bin/qemu-kvm") or
|
||||
os.path.exists("/usr/bin/kvm") or
|
||||
os.path.exists("/usr/libexec/qemu-kvm") or
|
||||
glob.glob("/usr/bin/qemu-system-*")):
|
||||
return "qemu:///system"
|
||||
|
||||
if (os.path.exists("/usr/lib/libvirt/libvirt_lxc") or
|
||||
os.path.exists("/usr/lib64/libvirt/libvirt_lxc")):
|
||||
return "lxc:///"
|
||||
return None
|
||||
return _default_uri()
|
||||
|
||||
def cancel(self, ignore1=None, ignore2=None):
|
||||
log.debug("Cancelling open connection")
|
||||
|
@ -142,7 +146,7 @@ class vmmCreateConn(vmmGObjectUI):
|
|||
default = self.default_uri()
|
||||
if not default or default.startswith("qemu"):
|
||||
uiutil.set_list_selection(self.widget("hypervisor"), HV_QEMU)
|
||||
elif default.startswith("xen"):
|
||||
elif default.startswith("xen"): # pragma: no cover
|
||||
uiutil.set_list_selection(self.widget("hypervisor"), HV_XEN)
|
||||
|
||||
def hostname_changed(self, src_ignore):
|
||||
|
@ -275,6 +279,7 @@ class vmmCreateConn(vmmGObjectUI):
|
|||
conn = vmmConnectionManager.get_instance().add_conn(uri)
|
||||
conn.set_autoconnect(auto)
|
||||
if conn.is_active():
|
||||
self._conn_open_completed(conn, None)
|
||||
return
|
||||
|
||||
conn.connect_once("open-completed", self._conn_open_completed)
|
||||
|
|
Loading…
Reference in New Issue