Change in vdsm[master]: hostdev tests: refactor common PCI addresses

mpolednik at redhat.com mpolednik at redhat.com
Wed Jul 1 11:15:08 UTC 2015


Martin Polednik has uploaded a new change for review.

Change subject: hostdev tests: refactor common PCI addresses
......................................................................

hostdev tests: refactor common PCI addresses

Due to repetative nature of addresses in tests, this patch factors them
to a class attributes.

Change-Id: Id396f92a8f0454bb9b0abc36932fde1b67f6c9d1
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M tests/hostdevTests.py
1 file changed, 10 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/43101/1

diff --git a/tests/hostdevTests.py b/tests/hostdevTests.py
index 2f59a5b..66670d7 100644
--- a/tests/hostdevTests.py
+++ b/tests/hostdevTests.py
@@ -380,6 +380,12 @@
 @MonkeyClass(libvirtconnection, 'get', Connection)
 class HostdevCreationTests(XMLTestCase):
 
+    _PCI_ADDRESS = {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
+                    'function': '0x0', 'type': 'pci'}
+
+    _PCI_ADDRESS_XML = '<address bus="0x01" domain="0x0000" function="0x0" \
+        slot="0x02" type="pci"/>'
+
     def setUp(self):
         self.conf = {
             'vmName': 'testVm',
@@ -399,14 +405,12 @@
                       _PCI_DEVICES))
     def testCreatePCIHostDeviceWithAddress(self, device_name):
         dev_spec = {'type': 'hostdev', 'device': device_name, 'address':
-                    {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
-                     'function': '0x0', 'type': 'pci'}}
+                    self._PCI_ADDRESS}
         device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
         self.assertXMLEqual(
             device.getXML().toxml(),
             _DEVICE_XML[device_name] %
-            ('<address bus="0x01" domain="0x0000" function="0x0" slot="0x02" \
-             type="pci"/>'))
+            (self._PCI_ADDRESS_XML))
 
     def testCreateSRIOVVF(self):
         dev_spec = {'type': 'hostdev', 'device': _SRIOV_VF,
@@ -420,11 +424,8 @@
         dev_spec = {'type': 'hostdev', 'device': _SRIOV_VF,
                     'specParams':
                     {'macAddr': 'ff:ff:ff:ff:ff:ff', 'vlanId': 3}, 'address':
-                    {'slot': '0x02', 'bus': '0x01', 'domain': '0x0000',
-                     'function': '0x0', 'type': 'pci'}}
+                    self._PCI_ADDRESS}
         device = hostdevice.HostDevice(self.conf, self.log, **dev_spec)
         self.assertXMLEqual(
             device.getXML().toxml(),
-            _DEVICE_XML[_SRIOV_VF] %
-            ('<address bus="0x01" domain="0x0000" function="0x0" slot="0x02" \
-             type="pci"/>'))
+            _DEVICE_XML[_SRIOV_VF] % (self._PCI_ADDRESS_XML))


-- 
To view, visit https://gerrit.ovirt.org/43101
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id396f92a8f0454bb9b0abc36932fde1b67f6c9d1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list