Browse Source

OSP-244 Fix mock_response in TestBigSwitchMechDriverNetworksV2.test_create_network

Previously in test_create_network, there was a line of codes trying to modify http response status to 200, but the change was done after the http request was made. The code for modifiying the status also does not work. This change fixes this issue.

Also adds a print statement help with debug as the Error with test_create_network was not stable.

Change-Id: I7ad2c8777376bb6f82c7d313900b084424d5f0d3
Weifan Fu 6 months ago
parent
commit
28f4dab37b

+ 6
- 2
networking_bigswitch/tests/unit/ml2/drivers/test_bigswitch_mech.py View File

@@ -37,6 +37,8 @@ from networking_bigswitch.plugins.bigswitch import config as pl_config
37 37
 from networking_bigswitch.plugins.bigswitch import servermanager
38 38
 from networking_bigswitch.plugins.ml2.drivers.mech_bigswitch \
39 39
     import driver as bsn_driver
40
+from networking_bigswitch.tests.unit.bigswitch.fake_server \
41
+    import HTTPResponseMock
40 42
 import networking_bigswitch.tests.unit.bigswitch.test_restproxy_plugin as trp
41 43
 from oslo_utils import uuidutils
42 44
 
@@ -82,9 +84,11 @@ class TestBigSwitchMechDriverNetworksV2(test_db_base_plugin_v2.TestNetworksV2,
82 84
                 ('status', self.net_create_status), ('shared', False)]
83 85
 
84 86
         with mock.patch(HTTPCON) as conmock:
87
+            rv = conmock.return_value
88
+            rv.getresponse.return_value = HTTPResponseMock(None)
85 89
             with self.network(name=name) as net:
86
-                rv = conmock.return_value
87
-                rv.getresponse.return_value.status = 200
90
+                # for debug
91
+                print (rv.request.mock_calls)
88 92
                 network = jsonutils.loads(rv.request.mock_calls[0][1][2])
89 93
                 self.assertIn('tenant_name', network['network'])
90 94
                 self.assertEqual('tenant_name',

Loading…
Cancel
Save