[PATCH 5/5] Use blivet's Size class instead of ints and such.
Chris Lumens
clumens at redhat.com
Wed Nov 12 18:32:46 UTC 2014
---
tests/gui/outside/__init__.py | 7 +++++--
tests/gui/outside/test_reclaim.py | 6 ++++--
tests/gui/outside/test_simplelivecd.py | 4 +++-
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tests/gui/outside/__init__.py b/tests/gui/outside/__init__.py
index 5d364fb..0e2f652 100644
--- a/tests/gui/outside/__init__.py
+++ b/tests/gui/outside/__init__.py
@@ -49,7 +49,7 @@ class Creator(object):
attributes:
drives -- A list of tuples describing disk images to create. Each
- tuple is the name and size, in GB.
+ tuple is the name of the drive and its size as a blivet.Size.
environ -- A dictionary of environment variables that should be added
to the environment the test suite will run under.
name -- A unique string that names a Creator. This name will
@@ -118,7 +118,10 @@ class Creator(object):
(fd, diskimage) = tempfile.mkstemp(dir=self.tempdir)
eintr_retry_call(os.close, fd)
- subprocess.call(["/usr/bin/qemu-img", "create", "-f", "raw", diskimage, "%sG" % size],
+ # For now we are using qemu-img to create these files but specifying
+ # sizes in blivet Size objects. Unfortunately, qemu-img wants sizes
+ # as xM or xG, not xMB or xGB. That's what the conversion here is for.
+ subprocess.call(["/usr/bin/qemu-img", "create", "-f", "raw", diskimage, "%sM" % size.convertTo(spec="MB")],
stdout=open("/dev/null", "w"))
self._drivePaths[drive] = diskimage
diff --git a/tests/gui/outside/test_reclaim.py b/tests/gui/outside/test_reclaim.py
index 8f7de0d..ebcaacf 100644
--- a/tests/gui/outside/test_reclaim.py
+++ b/tests/gui/outside/test_reclaim.py
@@ -23,8 +23,10 @@ from . import Creator, OutsideMixin
import subprocess
import unittest
+from blivet.size import Size
+
class BasicReclaimLiveCDCreator(Creator):
- drives = [("one", 8)]
+ drives = [("one", Size("8 GB"))]
name = "basicreclaimlivecd"
# This does not test every spoke, as we only need to do enough to satisfy anaconda
@@ -45,7 +47,7 @@ class BasicReclaimLiveCDCreator(Creator):
subprocess.call(["/sbin/parted", "-s", self._drivePaths[drive], "mklabel", "msdos"],
stdout=open("/dev/null", "w"),
stderr=open("/dev/null", "w"))
- subprocess.call(["/sbin/parted", "-s", self._drivePaths[drive], "mkpart", "p", "ext2", "0", str(size) + "G"],
+ subprocess.call(["/sbin/parted", "-s", self._drivePaths[drive], "mkpart", "p", "ext2", "0", str(size)],
stdout=open("/dev/null", "w"),
stderr=open("/dev/null", "w"))
subprocess.call(["/sbin/mkfs.ext4", "-F", self._drivePaths[drive]],
diff --git a/tests/gui/outside/test_simplelivecd.py b/tests/gui/outside/test_simplelivecd.py
index 7f9c485..0c4335d 100644
--- a/tests/gui/outside/test_simplelivecd.py
+++ b/tests/gui/outside/test_simplelivecd.py
@@ -22,8 +22,10 @@ __all__ = ["SimpleLiveCDCreator", "SimpleLiveCD_OutsideTest"]
from . import Creator, OutsideMixin
import unittest
+from blivet.size import Size
+
class SimpleLiveCDCreator(Creator):
- drives = [("one", 8)]
+ drives = [("one", Size("8 GB"))]
name = "simplelivecd"
tests = [("welcome", "BasicWelcomeTestCase"),
("summary", "LiveCDSummaryTestCase"),
--
1.9.3
More information about the anaconda-patches
mailing list