[master 15/17] Get rid of abitrary _resizable variable in tests.
mulkieran
installerbot-noreply at redhat.com
Thu Apr 23 16:39:52 UTC 2015
From: mulhern <amulhern at redhat.com>
Related: #12
Check if the filesystem has resizing abilities instead.
Signed-off-by: mulhern <amulhern at redhat.com>
---
tests/formats_test/fs_test.py | 14 ------------
tests/formats_test/fstesting.py | 49 +++++++++++++++++++++--------------------
2 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/tests/formats_test/fs_test.py b/tests/formats_test/fs_test.py
index 2b22de3..71fa524 100755
--- a/tests/formats_test/fs_test.py
+++ b/tests/formats_test/fs_test.py
@@ -12,7 +12,6 @@
class Ext2FSTestCase(fstesting.FSAsRoot):
_fs_class = fs.Ext2FS
- _resizable = True
class Ext3FSTestCase(Ext2FSTestCase):
_fs_class = fs.Ext3FS
@@ -22,42 +21,34 @@ class Ext4FSTestCase(Ext3FSTestCase):
class FATFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.FATFS
- _resizable = False
class EFIFSTestCase(FATFSTestCase):
_fs_class = fs.EFIFS
class BTRFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.BTRFS
- _resizable = False
@unittest.skip("Unable to create GFS2 filesystem.")
class GFS2TestCase(fstesting.FSAsRoot):
_fs_class = fs.GFS2
- _resizable = False
class JFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.JFS
- _resizable = False
class ReiserFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.ReiserFS
- _resizable = False
class XFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.XFS
- _resizable = False
class HFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.HFS
- _resizable = False
class AppleBootstrapFSTestCase(HFSTestCase):
_fs_class = fs.AppleBootstrapFS
class HFSPlusTestCase(fstesting.FSAsRoot):
_fs_class = fs.HFSPlus
- _resizable = False
class MacEFIFSTestCase(HFSPlusTestCase):
_fs_class = fs.MacEFIFS
@@ -65,24 +56,20 @@ class MacEFIFSTestCase(HFSPlusTestCase):
@unittest.skip("Unable to create because NTFS._formattable is False.")
class NTFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NTFS
- _resizable = True
@unittest.skip("Unable to create because device fails deviceCheck().")
class NFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NFS
- _resizable = False
class NFSv4TestCase(NFSTestCase):
_fs_class = fs.NFSv4
class Iso9660FS(fstesting.FSAsRoot):
_fs_class = fs.Iso9660FS
- _resizable = False
@unittest.skip("Too strange to test using this framework.")
class NoDevFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.NoDevFS
- _resizable = False
class DevPtsFSTestCase(NoDevFSTestCase):
_fs_class = fs.DevPtsFS
@@ -104,7 +91,6 @@ class USBFSTestCase(NoDevFSTestCase):
class BindFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.BindFS
- _resizable = False
class SimpleTmpFSTestCase(loopbackedtestcase.LoopBackedTestCase):
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
index 25646da..eb527f5 100644
--- a/tests/formats_test/fstesting.py
+++ b/tests/formats_test/fstesting.py
@@ -11,15 +11,21 @@
from blivet.size import Size, ROUND_DOWN
from blivet.formats import fs
+def can_resize(an_fs):
+ """ Returns True if this filesystem has all necessary resizing tools
+ available.
+
+ :param an_fs: a filesystem object
+ """
+ resize_tasks = (an_fs._resize, an_fs._sizeinfo, an_fs._minsize)
+ return all(not t.availabilityErrors for t in resize_tasks)
+
@add_metaclass(abc.ABCMeta)
class FSAsRoot(loopbackedtestcase.LoopBackedTestCase):
_fs_class = abc.abstractproperty(
doc="The class of the filesystem being tested on.")
- _resizable = abc.abstractproperty(
- doc="Should we expect to be able to resize this filesystem.")
-
_DEVICE_SIZE = Size("100 MiB")
def __init__(self, methodName='runTest'):
@@ -83,7 +89,7 @@ def testInstantiation(self):
self.assertEqual(an_fs.resizable, False)
# sizes
- expected_min_size = Size(0) if self._resizable else an_fs._minSize
+ expected_min_size = Size(0) if can_resize(an_fs) else an_fs._minSize
self.assertEqual(an_fs.minSize, expected_min_size)
self.assertEqual(an_fs.maxSize, an_fs._maxSize)
@@ -97,7 +103,7 @@ def testInstantiation(self):
an_fs = self._fs_class(size=NEW_SIZE)
# sizes
- expected_min_size = Size(0) if self._resizable else an_fs._minSize
+ expected_min_size = Size(0) if can_resize(an_fs) else an_fs._minSize
self.assertEqual(an_fs.minSize, expected_min_size)
self.assertEqual(an_fs.maxSize, an_fs._maxSize)
@@ -116,7 +122,7 @@ def testCreation(self):
self.assertTrue(an_fs.exists)
self.assertIsNone(an_fs.doCheck())
- expected_min_size = Size(0) if self._resizable else an_fs._minSize
+ expected_min_size = Size(0) if can_resize(an_fs) else an_fs._minSize
self.assertEqual(an_fs.minSize, expected_min_size)
self.assertEqual(an_fs.maxSize, an_fs._maxSize)
@@ -192,7 +198,7 @@ def testResize(self):
# CHECKME: target size is still 0 after updatedSizeInfo is called.
self.assertEqual(an_fs.size, Size(0) if an_fs.resizable else an_fs._size)
- if not self._resizable:
+ if not can_resize(an_fs):
self.assertFalse(an_fs.resizable)
# Not resizable, so can not do resizing actions.
with self.assertRaises(FSError):
@@ -221,10 +227,10 @@ def testNoExplicitTargetSize(self):
# _size if it is not set when size is calculated. Note that _targetSize
# gets value of _size in constructor, so if _size is set to not-zero
# in constructor call behavior would be different.
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
an_fs = self._fs_class()
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
@@ -244,11 +250,10 @@ def testNoExplicitTargetSize2(self):
""" Because _targetSize has been set to size in constructor the
resize action resizes filesystem to that size.
"""
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
-
SIZE = Size("64 MiB")
an_fs = self._fs_class(size=SIZE)
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
@@ -266,10 +271,9 @@ def testNoExplicitTargetSize2(self):
self._test_sizes(an_fs)
def testShrink(self):
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
-
an_fs = self._fs_class()
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
@@ -299,10 +303,9 @@ def testShrink(self):
self._test_sizes(an_fs)
def testTooSmall(self):
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
-
an_fs = self._fs_class()
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create or resize filesystem %s" % an_fs.name)
@@ -319,10 +322,9 @@ def testTooSmall(self):
self._test_sizes(an_fs)
def testTooBig(self):
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
-
an_fs = self._fs_class()
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
@@ -339,10 +341,9 @@ def testTooBig(self):
self._test_sizes(an_fs)
def testTooBig2(self):
- if not self._resizable:
- self.skipTest("Not checking resize for this test category.")
-
an_fs = self._fs_class()
+ if not can_resize(an_fs):
+ self.skipTest("Not checking resize for this test category.")
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/5b1912f14a56069601f438da66c40fd00f2c5ebc
More information about the anaconda-patches
mailing list