@@ -99,22 +99,28 @@ def test_add_del_interface_valid_ipv4(self):
9999 assert ('Eth36.10' , '32.11.10.1/24' ) in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
100100
101101 # config int ip remove Ethernet64 10.10.10.1/24
102- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet64" , "10.10.10.1/24" ], obj = obj )
103- print (result .exit_code , result .output )
104- assert result .exit_code != 0
105- assert ('Ethernet64' , '10.10.10.1/24' ) not in db .cfgdb .get_table ('INTERFACE' )
102+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
103+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet64" , "10.10.10.1/24" ], obj = obj )
104+ print (result .exit_code , result .output )
105+ assert result .exit_code == 0
106+ assert mock_run_command .call_count == 1
107+ assert ('Ethernet64' , '10.10.10.1/24' ) not in db .cfgdb .get_table ('INTERFACE' )
106108
107109 # config int ip remove Ethernet0.10 10.11.10.1/24
108- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet0.10" , "10.11.10.1/24" ], obj = obj )
109- print (result .exit_code , result .output )
110- assert result .exit_code != 0
111- assert ('Ethernet0.10' , '10.11.10.1/24' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
110+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
111+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet0.10" , "10.11.10.1/24" ], obj = obj )
112+ print (result .exit_code , result .output )
113+ assert result .exit_code == 0
114+ assert mock_run_command .call_count == 1
115+ assert ('Ethernet0.10' , '10.11.10.1/24' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
112116
113117 # config int ip remove Eth36.10 32.11.10.1/24
114- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Eth36.10" , "32.11.10.1/24" ], obj = obj )
115- print (result .exit_code , result .output )
116- assert result .exit_code != 0
117- assert ('Eth36.10' , '32.11.10.1/24' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
118+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
119+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Eth36.10" , "32.11.10.1/24" ], obj = obj )
120+ print (result .exit_code , result .output )
121+ assert result .exit_code == 0
122+ assert mock_run_command .call_count == 1
123+ assert ('Eth36.10' , '32.11.10.1/24' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
118124
119125 def test_add_interface_invalid_ipv4 (self ):
120126 db = Db ()
@@ -185,20 +191,26 @@ def test_add_del_interface_valid_ipv6(self):
185191 assert ('Eth36.10' , '3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
186192
187193 # config int ip remove Ethernet72 2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34
188- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet72" , "2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
189- print (result .exit_code , result .output )
190- assert result .exit_code != 0
191- assert ('Ethernet72' , '2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('INTERFACE' )
192-
193- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet0.10" , "1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
194- print (result .exit_code , result .output )
195- assert result .exit_code != 0
196- assert ('Ethernet0.10' , '1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
197-
198- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Eth36.10" , "3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
199- print (result .exit_code , result .output )
200- assert result .exit_code != 0
201- assert ('Eth36.10' , '3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
194+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
195+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet72" , "2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
196+ print (result .exit_code , result .output )
197+ assert result .exit_code == 0
198+ assert mock_run_command .call_count == 1
199+ assert ('Ethernet72' , '2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('INTERFACE' )
200+
201+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
202+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet0.10" , "1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
203+ print (result .exit_code , result .output )
204+ assert result .exit_code == 0
205+ assert mock_run_command .call_count == 1
206+ assert ('Ethernet0.10' , '1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
207+
208+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
209+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Eth36.10" , "3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34" ], obj = obj )
210+ print (result .exit_code , result .output )
211+ assert result .exit_code == 0
212+ assert mock_run_command .call_count == 1
213+ assert ('Eth36.10' , '3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
202214
203215 def test_del_interface_case_sensitive_ipv6 (self ):
204216 db = Db ()
@@ -209,10 +221,12 @@ def test_del_interface_case_sensitive_ipv6(self):
209221 assert ('Ethernet72' , 'FC00::1/126' ) in db .cfgdb .get_table ('INTERFACE' )
210222
211223 # config int ip remove Ethernet72 FC00::1/126
212- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet72" , "FC00::1/126" ], obj = obj )
213- print (result .exit_code , result .output )
214- assert result .exit_code != 0
215- assert ('Ethernet72' , 'FC00::1/126' ) not in db .cfgdb .get_table ('INTERFACE' )
224+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
225+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet72" , "FC00::1/126" ], obj = obj )
226+ print (result .exit_code , result .output )
227+ assert result .exit_code == 0
228+ assert mock_run_command .call_count == 1
229+ assert ('Ethernet72' , 'FC00::1/126' ) not in db .cfgdb .get_table ('INTERFACE' )
216230
217231 def test_add_interface_invalid_ipv6 (self ):
218232 db = Db ()
@@ -248,10 +262,12 @@ def test_add_del_interface_ipv6_with_leading_zeros(self):
248262 assert ('Ethernet68' , '2001:db8:11a3:9d7:1f34:8a2e:7a0:765d/34' ) in db .cfgdb .get_table ('INTERFACE' )
249263
250264 # config int ip remove Ethernet68 2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d/34
251- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet68" , "2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d/34" ], obj = obj )
252- print (result .exit_code , result .output )
253- assert result .exit_code != 0
254- assert ('Ethernet68' , '2001:db8:11a3:9d7:1f34:8a2e:7a0:765d/34' ) not in db .cfgdb .get_table ('INTERFACE' )
265+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
266+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet68" , "2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d/34" ], obj = obj )
267+ print (result .exit_code , result .output )
268+ assert result .exit_code == 0
269+ assert mock_run_command .call_count == 1
270+ assert ('Ethernet68' , '2001:db8:11a3:9d7:1f34:8a2e:7a0:765d/34' ) not in db .cfgdb .get_table ('INTERFACE' )
255271
256272 def test_add_del_interface_shortened_ipv6_with_leading_zeros (self ):
257273 db = Db ()
@@ -265,10 +281,12 @@ def test_add_del_interface_shortened_ipv6_with_leading_zeros(self):
265281 assert ('Ethernet68' , '3000::1/64' ) in db .cfgdb .get_table ('INTERFACE' )
266282
267283 # config int ip remove Ethernet68 3000::001/64
268- result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet68" , "3000::001/64" ], obj = obj )
269- print (result .exit_code , result .output )
270- assert result .exit_code != 0
271- assert ('Ethernet68' , '3000::1/64' ) not in db .cfgdb .get_table ('INTERFACE' )
284+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
285+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ], ["Ethernet68" , "3000::001/64" ], obj = obj )
286+ print (result .exit_code , result .output )
287+ assert result .exit_code == 0
288+ assert mock_run_command .call_count == 1
289+ assert ('Ethernet68' , '3000::1/64' ) not in db .cfgdb .get_table ('INTERFACE' )
272290
273291 def test_intf_vrf_bind_unbind (self ):
274292 runner = CliRunner ()
0 commit comments