tests: Add *DIR helper variables
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
c36f232370
commit
38405a477c
|
@ -12,7 +12,7 @@ from virtinst import Capabilities
|
|||
from virtinst import DomainCapabilities
|
||||
|
||||
|
||||
DATADIR = "tests/data/capabilities"
|
||||
DATADIR = utils.DATADIR + "/capabilities"
|
||||
|
||||
|
||||
class TestCapabilities(unittest.TestCase):
|
||||
|
|
|
@ -32,7 +32,8 @@ os.environ["HOME"] = "/tmp"
|
|||
os.environ["DISPLAY"] = ":3.4"
|
||||
|
||||
TMP_IMAGE_DIR = "/tmp/__virtinst_cli_"
|
||||
XMLDIR = "tests/data/cli"
|
||||
_ABSXMLDIR = utils.DATADIR + "/cli"
|
||||
XMLDIR = os.path.relpath(_ABSXMLDIR, utils.TOPDIR)
|
||||
OLD_OSINFO = utils.has_old_osinfo()
|
||||
NO_OSINFO_UNATTEND = not unattended.OSInstallScript.have_new_libosinfo()
|
||||
HAS_ISOINFO = shutil.which("isoinfo")
|
||||
|
|
|
@ -28,7 +28,7 @@ DISKPOOL = "/dev/disk-pool"
|
|||
|
||||
local_files = [FILE1, FILE2]
|
||||
|
||||
clonexml_dir = os.path.join(os.getcwd(), "tests/data/clone")
|
||||
CLONEXML_DIR = os.path.join(utils.DATADIR, "clone")
|
||||
|
||||
|
||||
class TestClone(unittest.TestCase):
|
||||
|
@ -45,7 +45,7 @@ class TestClone(unittest.TestCase):
|
|||
skip_list=None, compare=True, conn=None,
|
||||
clone_disks_file=None):
|
||||
"""Helper for comparing clone input/output from 2 xml files"""
|
||||
infile = os.path.join(clonexml_dir, filebase + "-in.xml")
|
||||
infile = os.path.join(CLONEXML_DIR, filebase + "-in.xml")
|
||||
in_content = open(infile).read()
|
||||
|
||||
if not conn:
|
||||
|
@ -100,7 +100,7 @@ class TestClone(unittest.TestCase):
|
|||
|
||||
def _clone_compare(self, cloneobj, outbase, clone_disks_file=None):
|
||||
"""Helps compare output from passed clone instance with an xml file"""
|
||||
outfile = os.path.join(clonexml_dir, outbase + "-out.xml")
|
||||
outfile = os.path.join(CLONEXML_DIR, outbase + "-out.xml")
|
||||
|
||||
cloneobj.setup_original()
|
||||
cloneobj.setup_clone()
|
||||
|
@ -115,7 +115,7 @@ class TestClone(unittest.TestCase):
|
|||
def _clone_define(self, filebase):
|
||||
"""Take the valid output xml and attempt to define it on the
|
||||
connection to ensure we don't get any errors"""
|
||||
outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
|
||||
outfile = os.path.join(CLONEXML_DIR, filebase + "-out.xml")
|
||||
outxml = open(outfile).read()
|
||||
conn = utils.URIs.open_testdriver_cached()
|
||||
utils.test_create(conn, outxml)
|
||||
|
@ -149,7 +149,7 @@ class TestClone(unittest.TestCase):
|
|||
def testCloneStorageCrossPool(self):
|
||||
conn = utils.URIs.open_test_remote()
|
||||
clone_disks_file = os.path.join(
|
||||
clonexml_dir, "cross-pool-disks-out.xml")
|
||||
CLONEXML_DIR, "cross-pool-disks-out.xml")
|
||||
disks = ["%s/new1.img" % POOL2, "%s/new2.img" % POOL1]
|
||||
self._clone("cross-pool", disks=disks,
|
||||
clone_disks_file=clone_disks_file, conn=conn)
|
||||
|
|
|
@ -22,6 +22,8 @@ funky_chars_xml = """
|
|||
</device>
|
||||
"""
|
||||
|
||||
DATADIR = utils.DATADIR + "/nodedev/"
|
||||
|
||||
|
||||
class TestNodeDev(unittest.TestCase):
|
||||
@property
|
||||
|
@ -34,7 +36,7 @@ class TestNodeDev(unittest.TestCase):
|
|||
return NodeDevice(self.conn, xml)
|
||||
|
||||
def _testNode2DeviceCompare(self, nodename, devfile, nodedev=None):
|
||||
devfile = os.path.join("tests/data/nodedev/devxml", devfile)
|
||||
devfile = os.path.join(DATADIR, "devxml", devfile)
|
||||
if not nodedev:
|
||||
nodedev = self._nodeDevFromName(nodename)
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# This work is licensed under the GNU GPLv2 or later.
|
||||
# See the COPYING file in the top-level directory.
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from virtinst import Guest
|
||||
|
@ -81,7 +80,7 @@ class TestOSDB(unittest.TestCase):
|
|||
assert str(e).endswith("URL location")
|
||||
|
||||
# Trigger an error path for code coverage
|
||||
self.assertEqual(OSDB.guess_os_by_tree(os.getcwd()), None)
|
||||
self.assertEqual(OSDB.guess_os_by_tree(utils.TESTDIR), None)
|
||||
|
||||
def test_kernel_url(self):
|
||||
def _c(name):
|
||||
|
|
|
@ -14,7 +14,7 @@ from tests import utils
|
|||
# pylint: disable=protected-access
|
||||
# Access to protected member, needed to unittest stuff
|
||||
|
||||
basepath = os.path.join(os.getcwd(), "tests", "data", "storage")
|
||||
BASEPATH = os.path.join(utils.DATADIR, "storage")
|
||||
|
||||
|
||||
def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
|
||||
|
@ -53,7 +53,7 @@ def removePool(poolobj):
|
|||
|
||||
def poolCompare(pool_inst):
|
||||
pool_inst.validate()
|
||||
filename = os.path.join(basepath, pool_inst.name + ".xml")
|
||||
filename = os.path.join(BASEPATH, pool_inst.name + ".xml")
|
||||
out_expect = pool_inst.get_xml()
|
||||
|
||||
if not os.path.exists(filename):
|
||||
|
@ -94,7 +94,7 @@ def createVol(conn, poolobj, volname=None, input_vol=None, clone_vol=None):
|
|||
vol_inst.name = volname
|
||||
|
||||
vol_inst.validate()
|
||||
filename = os.path.join(basepath, vol_inst.name + ".xml")
|
||||
filename = os.path.join(BASEPATH, vol_inst.name + ".xml")
|
||||
utils.diff_compare(vol_inst.get_xml(), filename)
|
||||
return vol_inst.install(meter=False)
|
||||
|
||||
|
|
|
@ -120,13 +120,13 @@ class TestXMLMisc(unittest.TestCase):
|
|||
# Simple sanity test to make sure detect_distro works. test-urls
|
||||
# does much more exhaustive testing but it's only run occasionally
|
||||
i = _make_installer(
|
||||
location="tests/data/cli/fakefedoratree")
|
||||
location=utils.DATADIR + "/cli/fakefedoratree")
|
||||
g = _make_guest()
|
||||
v = i.detect_distro(g)
|
||||
self.assertEqual(v, "fedora17")
|
||||
|
||||
i = _make_installer(
|
||||
location="tests/data/cli/fakerhel6tree")
|
||||
location=utils.DATADIR + "/cli/fakerhel6tree")
|
||||
g = _make_guest()
|
||||
v = i.detect_distro(g)
|
||||
self.assertEqual(v, "rhel6.0")
|
||||
|
|
|
@ -12,7 +12,7 @@ import virtinst
|
|||
from tests import utils
|
||||
|
||||
|
||||
DATADIR = "tests/data/xmlparse/"
|
||||
DATADIR = utils.DATADIR + "/xmlparse/"
|
||||
|
||||
|
||||
def sanitize_file_xml(xml):
|
||||
|
@ -1277,7 +1277,7 @@ class XMLParseTest(unittest.TestCase):
|
|||
|
||||
def testISCSIPool(self):
|
||||
basename = "pool-iscsi"
|
||||
infile = "tests/data/storage/%s.xml" % basename
|
||||
infile = utils.DATADIR + "/storage/%s.xml" % basename
|
||||
outfile = DATADIR + "%s-out.xml" % basename
|
||||
pool = virtinst.StoragePool(self.conn, parsexml=open(infile).read())
|
||||
|
||||
|
@ -1291,7 +1291,7 @@ class XMLParseTest(unittest.TestCase):
|
|||
|
||||
def testGlusterPool(self):
|
||||
basename = "pool-gluster"
|
||||
infile = "tests/data/storage/%s.xml" % basename
|
||||
infile = utils.DATADIR + "/storage/%s.xml" % basename
|
||||
outfile = DATADIR + "%s-out.xml" % basename
|
||||
pool = virtinst.StoragePool(self.conn, parsexml=open(infile).read())
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ def _search_permissions_decorator(fn):
|
|||
def wrapper(self, *args, **kwargs):
|
||||
# Generate capabilities XML from a template, with out
|
||||
# UID/GID inserted as the intended emulator permissions
|
||||
capsfile = (os.path.dirname(__file__) +
|
||||
"/data/capabilities/dac-caps-template.xml")
|
||||
capsfile = (tests.utils.UITESTDATADIR +
|
||||
"/capabilities/dac-caps-template.xml")
|
||||
capsdata = open(capsfile).read() % {
|
||||
"UID": os.getuid(), "GID": os.getgid()}
|
||||
tmpcaps = tempfile.NamedTemporaryFile(
|
||||
|
|
|
@ -7,6 +7,7 @@ import libvirt
|
|||
|
||||
from virtinst import log
|
||||
|
||||
import tests
|
||||
from tests.uitests import utils as uiutils
|
||||
|
||||
|
||||
|
@ -17,8 +18,7 @@ def _vm_wrapper(vmname, uri="qemu:///system", opts=None):
|
|||
def wrap1(fn):
|
||||
def wrapper(self, *args, **kwargs):
|
||||
self.app.error_if_already_running()
|
||||
xmlfile = "%s/data/live/%s.xml" % (
|
||||
os.path.dirname(__file__), vmname)
|
||||
xmlfile = "%s/live/%s.xml" % (tests.utils.UITESTDATADIR, vmname)
|
||||
conn = libvirt.open(uri)
|
||||
dom = conn.defineXML(open(xmlfile).read())
|
||||
try:
|
||||
|
|
|
@ -556,7 +556,7 @@ class VMMDogtailApp(object):
|
|||
stderr = open(os.devnull)
|
||||
|
||||
cmd = [sys.executable]
|
||||
cmd += [os.path.join(os.getcwd(), "virt-manager")]
|
||||
cmd += [os.path.join(tests.utils.TOPDIR, "virt-manager")]
|
||||
if no_fork:
|
||||
cmd += ["--no-fork"]
|
||||
if use_uri:
|
||||
|
@ -581,7 +581,7 @@ class VMMDogtailApp(object):
|
|||
if keyfile:
|
||||
import atexit
|
||||
import tempfile
|
||||
keyfile = os.path.dirname(__file__) + "/data/keyfile/" + keyfile
|
||||
keyfile = tests.utils.UITESTDATADIR + "/keyfile/" + keyfile
|
||||
tempname = tempfile.mktemp(prefix="virtmanager-uitests-keyfile")
|
||||
open(tempname, "w").write(open(keyfile).read())
|
||||
atexit.register(lambda: os.unlink(tempname))
|
||||
|
|
|
@ -34,6 +34,11 @@ class _TestConfig(object):
|
|||
|
||||
|
||||
TESTCONFIG = _TestConfig()
|
||||
TESTDIR = os.path.abspath(os.path.dirname(__file__))
|
||||
TOPDIR = os.path.dirname(TESTDIR)
|
||||
DATADIR = os.path.join(TESTDIR, "data")
|
||||
UITESTDIR = os.path.join(TESTDIR, "uitests")
|
||||
UITESTDATADIR = os.path.join(UITESTDIR, "data")
|
||||
|
||||
|
||||
def has_old_osinfo():
|
||||
|
@ -52,7 +57,7 @@ class _URIs(object):
|
|||
self._testdriver_error = None
|
||||
self._testdriver_default = None
|
||||
|
||||
_capspath = "%s/tests/data/capabilities/" % os.getcwd()
|
||||
_capspath = DATADIR + "/capabilities/"
|
||||
def _domcaps(path):
|
||||
return ",domcaps=" + _capspath + path
|
||||
def _caps(path):
|
||||
|
@ -61,7 +66,7 @@ class _URIs(object):
|
|||
_testtmpl = "__virtinst_test__test://%s,predictable"
|
||||
self.test_default = _testtmpl % "/default"
|
||||
|
||||
_testdriverdir = (os.path.dirname(__file__) + "/data/testdriver/")
|
||||
_testdriverdir = DATADIR + "/testdriver/"
|
||||
self.test_full = _testtmpl % (_testdriverdir + "testdriver.xml")
|
||||
self.test_suite = _testtmpl % (_testdriverdir + "testsuite.xml")
|
||||
self.test_defaultpool_collision = _testtmpl % (
|
||||
|
|
Loading…
Reference in New Issue