14
14
15
15
import json
16
16
from io import StringIO
17
-
17
+ from copy import deepcopy
18
18
import pytest
19
19
from ansible .module_utils ._text import to_text
20
20
from ansible .module_utils .six .moves .urllib .error import HTTPError , URLError
@@ -206,9 +206,9 @@ def test_validate_input_success(self, addr_param):
206
206
f_module = self .get_module_mock (params = addr_param ["in" ])
207
207
self .module .validate_input (f_module )
208
208
209
- @pytest .mark .parametrize ("param" , [{"in" : inp_param , "device" : chassis , "enable_nic" : False , "delay" : 5 ,
209
+ @pytest .mark .parametrize ("param" , [{"in" : deepcopy ( inp_param ) , "device" : deepcopy ( chassis ) , "enable_nic" : False , "delay" : 5 ,
210
210
"diff" : {'EnableNIC' : False , 'Delay' : 5 }},
211
- {"in" : inp_param , "device" : chassis , "enable_nic" : True ,
211
+ {"in" : deepcopy ( inp_param ) , "device" : deepcopy ( chassis ) , "enable_nic" : True ,
212
212
"diff" : {'StaticAlternateDNSServer' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f121' ,
213
213
'StaticPreferredDNSServer' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f122' ,
214
214
'StaticGateway' : '0000::ffff' , 'StaticSubnetMask' : '255.255.255.0' ,
@@ -217,24 +217,24 @@ def test_validate_input_success(self, addr_param):
217
217
'StaticPrefixLength' : 0 , 'EnableIPv6' : True , 'NetworkSpeed' : '10_MB' ,
218
218
'DnsName' : 'openmanage-enterprise' , 'AutoNegotiation' : False ,
219
219
'DnsDomainName' : 'localdomain' , 'MgmtVLANId' : 0 }},
220
- {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : chassis ,
220
+ {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : deepcopy ( chassis ) ,
221
221
"enable_nic" : True ,
222
222
"diff" : {'StaticAlternateDNSServer' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f121' ,
223
223
'StaticPreferredDNSServer' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f122' ,
224
224
'StaticGateway' : '0000::ffff' ,
225
225
'StaticIPv6Address' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f120' ,
226
226
'StaticPrefixLength' : 0 , 'EnableIPv6' : True }},
227
- {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : chassis ,
227
+ {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : deepcopy ( chassis ) ,
228
228
"enable_nic" : True ,
229
229
"diff" : {'StaticAlternateDNSServer' : '192.168.11.3' ,
230
230
'StaticPreferredDNSServer' : '192.168.11.2' ,
231
231
'StaticGateway' : '192.168.11.1' , 'StaticSubnetMask' : '255.255.255.0' ,
232
232
'StaticIPAddress' : '192.168.11.20' }},
233
- {"in" : {"dns_configuration" : dns_configuration }, "device" : chassis ,
233
+ {"in" : {"dns_configuration" : dns_configuration }, "device" : deepcopy ( chassis ) ,
234
234
"enable_nic" : True ,
235
235
"diff" : {'NetworkSpeed' : '10_MB' , 'DnsName' : 'openmanage-enterprise' ,
236
236
'AutoNegotiation' : False , 'DnsDomainName' : 'localdomain' }},
237
- {"in" : {"management_vlan" : management_vlan }, "device" : chassis ,
237
+ {"in" : {"management_vlan" : management_vlan }, "device" : deepcopy ( chassis ) ,
238
238
"enable_nic" : True ,
239
239
"diff" : {'MgmtVLANId' : 0 }}])
240
240
def test_update_chassis_payload_success (self , param ):
@@ -245,9 +245,9 @@ def test_update_chassis_payload_success(self, param):
245
245
diff = self .module .update_chassis_payload (f_module , param ["device" ])
246
246
assert diff == param .get ("diff" )
247
247
248
- @pytest .mark .parametrize ("param" , [{"in" : inp_param , "device" : server , "enable_nic" : False ,
248
+ @pytest .mark .parametrize ("param" , [{"in" : deepcopy ( inp_param ) , "device" : deepcopy ( server ) , "enable_nic" : False ,
249
249
"diff" : {'enableNIC' : 'Disabled' }},
250
- {"in" : inp_param , "device" : server , "enable_nic" : True ,
250
+ {"in" : deepcopy ( inp_param ) , "device" : deepcopy ( server ) , "enable_nic" : True ,
251
251
"diff" : {'staticIPAddressIPv4' : '192.168.11.20' ,
252
252
'staticSubnetMaskIPv4' : '255.255.255.0' ,
253
253
'staticGatewayIPv4' : '192.168.11.1' ,
@@ -261,20 +261,20 @@ def test_update_chassis_payload_success(self, param):
261
261
'staticPrefixLengthIPv6' : 0 , 'staticGatewayIPv6' : '0000::ffff' ,
262
262
'enableIPv6' : 'Enabled' ,
263
263
'vlanId' : 0 }},
264
- {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : server ,
264
+ {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : deepcopy ( server ) ,
265
265
"enable_nic" : True ,
266
266
"diff" : {'staticPreferredDNSIPv6' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f122' ,
267
267
'staticAlternateDNSIPv6' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f121' ,
268
268
'staticIPAddressIPv6' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f120' ,
269
269
'staticPrefixLengthIPv6' : 0 , 'staticGatewayIPv6' : '0000::ffff' ,
270
270
'enableAutoConfigurationIPv6' : 'Disabled' , 'enableIPv6' : 'Enabled' }},
271
- {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : server ,
271
+ {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : deepcopy ( server ) ,
272
272
"enable_nic" : True , "diff" : {'staticIPAddressIPv4' : '192.168.11.20' ,
273
273
'staticSubnetMaskIPv4' : '255.255.255.0' ,
274
274
'staticGatewayIPv4' : '192.168.11.1' ,
275
275
'staticPreferredDNSIPv4' : '192.168.11.2' ,
276
276
'staticAlternateDNSIPv4' : '192.168.11.3' }},
277
- {"in" : {"management_vlan" : management_vlan }, "device" : server ,
277
+ {"in" : {"management_vlan" : management_vlan }, "device" : deepcopy ( server ) ,
278
278
"enable_nic" : True , "diff" : {'vlanEnable' : 'Enabled' , 'vlanId' : 0 }}
279
279
])
280
280
def test_update_server_payload_success (self , param ):
@@ -284,30 +284,30 @@ def test_update_server_payload_success(self, param):
284
284
diff = self .module .update_server_payload (f_module , param ["device" ])
285
285
assert diff == param .get ("diff" )
286
286
287
- @pytest .mark .parametrize ("param" , [{"in" : inp_param , "device" : iom , "enable_nic" : False ,
287
+ @pytest .mark .parametrize ("param" , [{"in" : deepcopy ( inp_param ) , "device" : deepcopy ( iom ) , "enable_nic" : False ,
288
288
"diff" : {'StaticGateway' : '0000::ffff' , 'StaticIPAddress' : '192.168.11.20' ,
289
289
'StaticSubnetMask' : '255.255.255.0' , 'EnableDHCP' : False ,
290
290
'EnableMgmtVLANId' : True ,
291
291
'StaticPrefixLength' : 0 ,
292
292
'StaticIPv6Address' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f120' ,
293
293
'MgmtVLANId' : 0 , 'SecondaryDNS' : '192.96.20.182' ,
294
294
'PrimaryDNS' : '192.96.20.181' }},
295
- {"in" : inp_param , "device" : iom , "enable_nic" : True ,
295
+ {"in" : deepcopy ( inp_param ) , "device" : deepcopy ( iom ) , "enable_nic" : True ,
296
296
"diff" : {'StaticGateway' : '0000::ffff' , 'StaticIPAddress' : '192.168.11.20' ,
297
297
'StaticSubnetMask' : '255.255.255.0' , 'EnableDHCP' : False ,
298
298
'StaticPrefixLength' : 0 , 'EnableMgmtVLANId' : True ,
299
299
'StaticIPv6Address' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f120' ,
300
300
'MgmtVLANId' : 0 , 'SecondaryDNS' : '192.96.20.182' ,
301
301
'PrimaryDNS' : '192.96.20.181' }},
302
- {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : iom ,
302
+ {"in" : {"ipv6_configuration" : ipv6_configuration }, "device" : deepcopy ( iom ) ,
303
303
"enable_nic" : True , "diff" : {'StaticGateway' : '0000::ffff' ,
304
304
'StaticPrefixLength' : 0 ,
305
305
'StaticIPv6Address' : '2607:f2b1:f081:9:1c8c:f1c7:47e:f120' }},
306
- {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : iom ,
306
+ {"in" : {"ipv4_configuration" : ipv4_configuration }, "device" : deepcopy ( iom ) ,
307
307
"enable_nic" : True ,
308
308
"diff" : {'StaticGateway' : '192.168.11.1' , 'StaticIPAddress' : '192.168.11.20' ,
309
309
'StaticSubnetMask' : '255.255.255.0' , 'EnableDHCP' : False }},
310
- {"in" : {"management_vlan" : management_vlan }, "device" : iom ,
310
+ {"in" : {"management_vlan" : management_vlan }, "device" : deepcopy ( iom ) ,
311
311
"enable_nic" : True , "diff" : {'EnableMgmtVLANId' : True , 'MgmtVLANId' : 0 }}
312
312
])
313
313
def test_update_iom_payload_success (self , param ):
0 commit comments