[blivet:master 07/21] Allow the RAID object itself to be a valid RAID descriptor for lookup.

mulhern amulhern at redhat.com
Sat May 17 18:50:52 UTC 2014


Update tests accordingly.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devicelibs/raid.py          | 5 ++++-
 tests/devicelibs_test/raid_test.py | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py
index deca88a..ec0ada0 100644
--- a/blivet/devicelibs/raid.py
+++ b/blivet/devicelibs/raid.py
@@ -302,11 +302,14 @@ class RAIDLevels(object):
 
            :param object descriptor: a RAID level descriptor
 
+           Note that descriptor may be any object that identifies a
+           RAID level, including the RAID object itself.
+
            Raises a RaidError if no RAID object can be found for this
            descriptor.
         """
         for level in self._raid_levels:
-            if descriptor in level.names:
+            if descriptor in level.names or descriptor == level:
                 return level
         raise RaidError("invalid RAID level descriptor %s" % descriptor)
 
diff --git a/tests/devicelibs_test/raid_test.py b/tests/devicelibs_test/raid_test.py
index e192aea..f32c59e 100644
--- a/tests/devicelibs_test/raid_test.py
+++ b/tests/devicelibs_test/raid_test.py
@@ -45,6 +45,7 @@ class RaidTestCase(unittest.TestCase):
         self.assertIs(self.levels.raidLevel("raid4"), raid.RAID4)
         self.assertIs(self.levels.raidLevel("mirror"), raid.RAID1)
         self.assertIs(self.levels.raidLevel("stripe"), raid.RAID0)
+        self.assertIs(self.levels.raidLevel(raid.RAID0), raid.RAID0)
 
         self.assertRaises(errors.RaidError, self.levels.raidLevel, "bogus")
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list