Browse Source

Fix issues introduced by zhmcclient and os-dpm version bump

The following version bumps happened recently
* zhmcclient=0.14
* os-dpm=1.1.0

Those caused a couple of issues with the test code in networking-dpm.
This patch fises them.

Change-Id: If0b69961b3933447288991cfad17fcdb9c0d3e30
Closes-bug: #1706590
Andreas Scheuring 1 year ago
parent
commit
fff6b1348d

+ 4
- 2
networking_dpm/tests/unit/conf/test_config.py View File

@@ -30,14 +30,16 @@ class TestConfig(base.BaseTestCase):
30 30
         cfg.CONF.set_override('hmc', 'hmc-ip', 'dpm')
31 31
         cfg.CONF.set_override('hmc_username', 'username', 'dpm')
32 32
         cfg.CONF.set_override('hmc_password', 'password', 'dpm')
33
-        cfg.CONF.set_override('cpc_object_id', 'oid', 'dpm')
33
+        cfg.CONF.set_override('cpc_object_id',
34
+                              'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'dpm')
34 35
         cfg.CONF.set_override('physical_network_adapter_mappings', mappings,
35 36
                               'dpm')
36 37
 
37 38
         self.assertEqual('hmc-ip', cfg.CONF.dpm.hmc)
38 39
         self.assertEqual('username', cfg.CONF.dpm.hmc_username)
39 40
         self.assertEqual('password', cfg.CONF.dpm.hmc_password)
40
-        self.assertEqual('oid', cfg.CONF.dpm.cpc_object_id)
41
+        self.assertEqual('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
42
+                         cfg.CONF.dpm.cpc_object_id)
41 43
         self.assertEqual(mappings_parsed,
42 44
                          cfg.CONF.dpm.physical_network_adapter_mappings)
43 45
 

+ 7
- 2
networking_dpm/tests/unit/fake_zhmcclient.py View File

@@ -13,6 +13,7 @@
13 13
 # limitations under the License.
14 14
 
15 15
 import json
16
+import mock
16 17
 from zhmcclient import NotFound
17 18
 from zhmcclient import NoUniqueMatch
18 19
 
@@ -30,6 +31,10 @@ the HMC. For an example, see the corresponding test case.
30 31
 """
31 32
 
32 33
 
34
+MANAGER_MOCK = mock.Mock()
35
+MANAGER_MOCK.resource_class.__name__ = "foo"
36
+
37
+
33 38
 class _BaseObject(object):
34 39
     def __init__(self, object_json):
35 40
         self.properties = object_json
@@ -56,9 +61,9 @@ class _BaseManager(object):
56 61
         matches = self.findall(**kwargs)
57 62
         num_matches = len(matches)
58 63
         if num_matches == 0:
59
-            raise NotFound
64
+            raise NotFound([], MANAGER_MOCK)
60 65
         elif num_matches > 1:
61
-            raise NoUniqueMatch
66
+            raise NoUniqueMatch([], MANAGER_MOCK)
62 67
         else:
63 68
             return matches[0]
64 69
 

+ 5
- 1
networking_dpm/tests/unit/ml2/test_dpm_neutron_agent.py View File

@@ -32,6 +32,9 @@ OID_A = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
32 32
 OID_B = "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
33 33
 OID_C = "cccccccc-cccc-cccc-cccc-cccccccccccc"
34 34
 
35
+MANAGER_MOCK = mock.Mock()
36
+MANAGER_MOCK.resource_class.__name__ = "foo"
37
+
35 38
 
36 39
 class TestPhysnetMapping(base.BaseTestCase):
37 40
 
@@ -278,7 +281,8 @@ class TestDPMManager(base.BaseTestCase):
278 281
 
279 282
     def test_get_all_devices_connection_error(self):
280 283
         vswitch_bad = mock.Mock()
281
-        vswitch_bad.get_connected_nics.side_effect = ConnectionError("foo")
284
+        vswitch_bad.get_connected_nics.side_effect = ConnectionError(
285
+            [], MANAGER_MOCK)
282 286
         self.mgr.vswitches = [vswitch_bad]
283 287
 
284 288
         devices = self.mgr.get_all_devices()

Loading…
Cancel
Save