mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-25 05:23:58 -07:00 
			
		
		
		
	nmcli: Typecast parameter values to string as required (#477)
This commit is contained in:
		
					parent
					
						
							
								8d80ffd8ca
							
						
					
				
			
			
				commit
				
					
						2aaab59d04
					
				
			
		
					 3 changed files with 48 additions and 43 deletions
				
			
		|  | @ -5,6 +5,7 @@ import json | |||
| 
 | ||||
| import pytest | ||||
| 
 | ||||
| from ansible.module_utils._text import to_text | ||||
| from ansible_collections.community.general.plugins.modules.net_tools import nmcli | ||||
| 
 | ||||
| pytestmark = pytest.mark.usefixtures('patch_ansible_module') | ||||
|  | @ -374,8 +375,8 @@ def test_create_bridge(mocked_generic_connection_create): | |||
|     assert args[0][5] == 'con-name' | ||||
|     assert args[0][6] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', 100, 'bridge.stp', 'yes']: | ||||
|         assert param in args[0] | ||||
|     for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', '100', 'bridge.stp', 'yes']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_BRIDGE, indirect=['patch_ansible_module']) | ||||
|  | @ -395,8 +396,8 @@ def test_mod_bridge(mocked_generic_connection_modify): | |||
|     assert args[0][1] == 'con' | ||||
|     assert args[0][2] == 'mod' | ||||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
|     for param in ['ipv4.address', '10.10.10.10', 'ipv4.gateway', '10.10.10.1', 'bridge.max-age', 100, 'bridge.stp', 'yes']: | ||||
|         assert param in args[0] | ||||
|     for param in ['ipv4.address', '10.10.10.10', 'ipv4.gateway', '10.10.10.1', 'bridge.max-age', '100', 'bridge.stp', 'yes']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_BRIDGE_SLAVE, indirect=['patch_ansible_module']) | ||||
|  | @ -420,8 +421,8 @@ def test_create_bridge_slave(mocked_generic_connection_create): | |||
|     assert args[0][5] == 'con-name' | ||||
|     assert args[0][6] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['bridge-port.path-cost', 100]: | ||||
|         assert param in args[0] | ||||
|     for param in ['bridge-port.path-cost', '100']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_BRIDGE_SLAVE, indirect=['patch_ansible_module']) | ||||
|  | @ -442,8 +443,8 @@ def test_mod_bridge_slave(mocked_generic_connection_modify): | |||
|     assert args[0][2] == 'mod' | ||||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['bridge-port.path-cost', 100]: | ||||
|         assert param in args[0] | ||||
|     for param in ['bridge-port.path-cost', '100']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_VLAN, indirect=['patch_ansible_module']) | ||||
|  | @ -468,7 +469,7 @@ def test_create_vlan_con(mocked_generic_connection_create): | |||
|     assert args[0][6] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'id', '10']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_VLAN, indirect=['patch_ansible_module']) | ||||
|  | @ -490,7 +491,7 @@ def test_mod_vlan_conn(mocked_generic_connection_modify): | |||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['ipv4.address', '10.10.10.10', 'ipv4.gateway', '10.10.10.1', 'vlan.id', '10']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_VXLAN, indirect=['patch_ansible_module']) | ||||
|  | @ -514,8 +515,8 @@ def test_create_vxlan(mocked_generic_connection_create): | |||
|     assert args[0][6] == 'non_existent_nw_device' | ||||
|     assert args[0][7] == 'ifname' | ||||
| 
 | ||||
|     for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', 11]: | ||||
|         assert param in args[0] | ||||
|     for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', '11']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_VXLAN, indirect=['patch_ansible_module']) | ||||
|  | @ -535,8 +536,8 @@ def test_vxlan_mod(mocked_generic_connection_modify): | |||
|     assert args[0][2] == 'mod' | ||||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', 11]: | ||||
|         assert param in args[0] | ||||
|     for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', '11']: | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_IPIP, indirect=['patch_ansible_module']) | ||||
|  | @ -566,7 +567,7 @@ def test_create_ipip(mocked_generic_connection_create): | |||
|     assert args[0][12] == 'non_existent_ipip_device' | ||||
| 
 | ||||
|     for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_IPIP, indirect=['patch_ansible_module']) | ||||
|  | @ -587,7 +588,7 @@ def test_ipip_mod(mocked_generic_connection_modify): | |||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_SIT, indirect=['patch_ansible_module']) | ||||
|  | @ -617,7 +618,7 @@ def test_create_sit(mocked_generic_connection_create): | |||
|     assert args[0][12] == 'non_existent_sit_device' | ||||
| 
 | ||||
|     for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_SIT, indirect=['patch_ansible_module']) | ||||
|  | @ -638,7 +639,7 @@ def test_sit_mod(mocked_generic_connection_modify): | |||
|     assert args[0][3] == 'non_existent_nw_device' | ||||
| 
 | ||||
|     for param in ['ip-tunnel.local', '192.168.225.5', 'ip-tunnel.remote', '192.168.225.6']: | ||||
|         assert param in args[0] | ||||
|         assert param in map(to_text, args[0]) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize('patch_ansible_module', TESTCASE_ETHERNET_DHCP, indirect=['patch_ansible_module']) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue