[Kimchi-devel] [PATCH 1/8] Rename test_storagepool.py to test_storagepoolxml.py

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jan 22 13:32:51 UTC 2015


Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 tests/test_storagepool.py    | 172 -------------------------------------------
 tests/test_storagepoolxml.py | 171 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 171 insertions(+), 172 deletions(-)
 delete mode 100644 tests/test_storagepool.py
 create mode 100644 tests/test_storagepoolxml.py

diff --git a/tests/test_storagepool.py b/tests/test_storagepool.py
deleted file mode 100644
index ee30e9a..0000000
--- a/tests/test_storagepool.py
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Project Kimchi
-#
-# Copyright IBM, Corp. 2014
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-import lxml.etree as ET
-import unittest
-
-
-from kimchi.model.libvirtstoragepool import StoragePoolDef
-
-
-class storagepoolTests(unittest.TestCase):
-    def test_get_storagepool_xml(self):
-        poolDefs = [
-            {'def':
-                {'type': 'dir',
-                 'name': 'unitTestDirPool',
-                 'path': '/var/temp/images'},
-             'xml':
-             """
-             <pool type='dir'>
-               <name>unitTestDirPool</name>
-               <target>
-                 <path>/var/temp/images</path>
-               </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'netfs',
-                 'name': 'unitTestNFSPool',
-                 'source': {'host': '127.0.0.1',
-                            'path': '/var/export'}},
-             'xml':
-             """
-             <pool type='netfs'>
-               <name>unitTestNFSPool</name>
-               <source>
-                 <host name='127.0.0.1'/>
-                 <dir path='/var/export'/>
-               </source>
-               <target>
-                 <path>/var/lib/kimchi/nfs_mount/unitTestNFSPool</path>
-               </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'logical',
-                 'name': 'unitTestLogicalPool',
-                 'source': {'devices': ['/dev/hda', '/dev/hdb']}},
-             'xml':
-             """
-             <pool type='logical'>
-             <name>unitTestLogicalPool</name>
-                 <source>
-                     <device path="/dev/hda" />
-                     <device path="/dev/hdb" />
-                 </source>
-             <target>
-                 <path>/dev/unitTestLogicalPool</path>
-             </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'iscsi',
-                 'name': 'unitTestISCSIPool',
-                 'source': {
-                     'host': '127.0.0.1',
-                     'target': 'iqn.2003-01.org.linux-iscsi.localhost'}},
-             'xml':
-             """
-             <pool type='iscsi'>
-               <name>unitTestISCSIPool</name>
-               <source>
-                 <host name='127.0.0.1' />
-                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
-               </source>
-               <target>
-                 <path>/dev/disk/by-id</path>
-               </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'iscsi',
-                 'name': 'unitTestISCSIPoolPort',
-                 'source': {
-                     'host': '127.0.0.1',
-                     'port': 3266,
-                     'target': 'iqn.2003-01.org.linux-iscsi.localhost'}},
-             'xml':
-             """
-             <pool type='iscsi'>
-               <name>unitTestISCSIPoolPort</name>
-               <source>
-                 <host name='127.0.0.1' port='3266' />
-                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
-               </source>
-               <target>
-                 <path>/dev/disk/by-id</path>
-               </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'iscsi',
-                 'name': 'unitTestISCSIPoolAuth',
-                 'source': {
-                     'host': '127.0.0.1',
-                     'target': 'iqn.2003-01.org.linux-iscsi.localhost',
-                     'auth': {'username': 'testUser',
-                              'password': 'ActuallyNotUsedInPoolXML'}}},
-             'xml':
-             """
-             <pool type='iscsi'>
-               <name>unitTestISCSIPoolAuth</name>
-               <source>
-                 <host name='127.0.0.1' />
-                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
-                 <auth type='chap' username='testUser'>
-                   <secret type='iscsi' usage='unitTestISCSIPoolAuth'/>
-                 </auth>
-               </source>
-               <target>
-                 <path>/dev/disk/by-id</path>
-               </target>
-             </pool>
-             """},
-            {'def':
-                {'type': 'scsi',
-                 'name': 'unitTestSCSIFCPool',
-                 'path': '/dev/disk/by-path',
-                 'source': {
-                     'name': 'scsi_host3',
-                     'adapter': {
-                         'type': 'fc_host',
-                         'wwpn': '0123456789abcdef',
-                         'wwnn': 'abcdef0123456789'}}},
-             'xml':
-             """
-             <pool type='scsi'>
-               <name>unitTestSCSIFCPool</name>
-               <source>
-                   <adapter type='fc_host' name='scsi_host3'
-                     wwnn='abcdef0123456789' wwpn='0123456789abcdef'></adapter>
-               </source>
-               <target>
-                   <path>/dev/disk/by-path</path>
-               </target>
-             </pool>
-             """}]
-
-        for poolDef in poolDefs:
-            defObj = StoragePoolDef.create(poolDef['def'])
-            xmlStr = defObj.xml
-
-            parser = ET.XMLParser(remove_blank_text=True)
-            t1 = ET.fromstring(xmlStr, parser)
-            t2 = ET.fromstring(poolDef['xml'], parser)
-            self.assertEquals(ET.tostring(t1), ET.tostring(t2))
diff --git a/tests/test_storagepoolxml.py b/tests/test_storagepoolxml.py
new file mode 100644
index 0000000..c508c58
--- /dev/null
+++ b/tests/test_storagepoolxml.py
@@ -0,0 +1,171 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import lxml.etree as ET
+import unittest
+
+from kimchi.model.libvirtstoragepool import StoragePoolDef
+
+
+class StoragepoolXMLTests(unittest.TestCase):
+    def test_get_storagepool_xml(self):
+        poolDefs = [
+            {'def':
+                {'type': 'dir',
+                 'name': 'unitTestDirPool',
+                 'path': '/var/temp/images'},
+             'xml':
+             """
+             <pool type='dir'>
+               <name>unitTestDirPool</name>
+               <target>
+                 <path>/var/temp/images</path>
+               </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'netfs',
+                 'name': 'unitTestNFSPool',
+                 'source': {'host': '127.0.0.1',
+                            'path': '/var/export'}},
+             'xml':
+             """
+             <pool type='netfs'>
+               <name>unitTestNFSPool</name>
+               <source>
+                 <host name='127.0.0.1'/>
+                 <dir path='/var/export'/>
+               </source>
+               <target>
+                 <path>/var/lib/kimchi/nfs_mount/unitTestNFSPool</path>
+               </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'logical',
+                 'name': 'unitTestLogicalPool',
+                 'source': {'devices': ['/dev/hda', '/dev/hdb']}},
+             'xml':
+             """
+             <pool type='logical'>
+             <name>unitTestLogicalPool</name>
+                 <source>
+                     <device path="/dev/hda" />
+                     <device path="/dev/hdb" />
+                 </source>
+             <target>
+                 <path>/dev/unitTestLogicalPool</path>
+             </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'iscsi',
+                 'name': 'unitTestISCSIPool',
+                 'source': {
+                     'host': '127.0.0.1',
+                     'target': 'iqn.2003-01.org.linux-iscsi.localhost'}},
+             'xml':
+             """
+             <pool type='iscsi'>
+               <name>unitTestISCSIPool</name>
+               <source>
+                 <host name='127.0.0.1' />
+                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
+               </source>
+               <target>
+                 <path>/dev/disk/by-id</path>
+               </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'iscsi',
+                 'name': 'unitTestISCSIPoolPort',
+                 'source': {
+                     'host': '127.0.0.1',
+                     'port': 3266,
+                     'target': 'iqn.2003-01.org.linux-iscsi.localhost'}},
+             'xml':
+             """
+             <pool type='iscsi'>
+               <name>unitTestISCSIPoolPort</name>
+               <source>
+                 <host name='127.0.0.1' port='3266' />
+                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
+               </source>
+               <target>
+                 <path>/dev/disk/by-id</path>
+               </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'iscsi',
+                 'name': 'unitTestISCSIPoolAuth',
+                 'source': {
+                     'host': '127.0.0.1',
+                     'target': 'iqn.2003-01.org.linux-iscsi.localhost',
+                     'auth': {'username': 'testUser',
+                              'password': 'ActuallyNotUsedInPoolXML'}}},
+             'xml':
+             """
+             <pool type='iscsi'>
+               <name>unitTestISCSIPoolAuth</name>
+               <source>
+                 <host name='127.0.0.1' />
+                 <device path='iqn.2003-01.org.linux-iscsi.localhost'/>
+                 <auth type='chap' username='testUser'>
+                   <secret type='iscsi' usage='unitTestISCSIPoolAuth'/>
+                 </auth>
+               </source>
+               <target>
+                 <path>/dev/disk/by-id</path>
+               </target>
+             </pool>
+             """},
+            {'def':
+                {'type': 'scsi',
+                 'name': 'unitTestSCSIFCPool',
+                 'path': '/dev/disk/by-path',
+                 'source': {
+                     'name': 'scsi_host3',
+                     'adapter': {
+                         'type': 'fc_host',
+                         'wwpn': '0123456789abcdef',
+                         'wwnn': 'abcdef0123456789'}}},
+             'xml':
+             """
+             <pool type='scsi'>
+               <name>unitTestSCSIFCPool</name>
+               <source>
+                   <adapter type='fc_host' name='scsi_host3'
+                     wwnn='abcdef0123456789' wwpn='0123456789abcdef'></adapter>
+               </source>
+               <target>
+                   <path>/dev/disk/by-path</path>
+               </target>
+             </pool>
+             """}]
+
+        for poolDef in poolDefs:
+            defObj = StoragePoolDef.create(poolDef['def'])
+            xmlStr = defObj.xml
+
+            parser = ET.XMLParser(remove_blank_text=True)
+            t1 = ET.fromstring(xmlStr, parser)
+            t2 = ET.fromstring(poolDef['xml'], parser)
+            self.assertEquals(ET.tostring(t1), ET.tostring(t2))
-- 
2.1.0




More information about the Kimchi-devel mailing list