@@ -105,6 +105,36 @@ def test_config_int_ip_rem_static(
105
105
assert result .exit_code == 0
106
106
assert mock_run_command .call_count == 1
107
107
108
+ @pytest .mark .parametrize ('setup_single_bgp_instance' ,
109
+ ['ip_route_for_int_ip' ], indirect = ['setup_single_bgp_instance' ])
110
+ def test_config_int_ip_rem_sub_intf (
111
+ self ,
112
+ get_cmd_module ,
113
+ setup_single_bgp_instance ):
114
+ (config , _ ) = get_cmd_module
115
+ jsonfile_config = os .path .join (mock_db_path , "config_db" )
116
+ from .mock_tables import dbconnector
117
+ dbconnector .dedicated_dbs ['CONFIG_DB' ] = jsonfile_config
118
+
119
+ runner = CliRunner ()
120
+ db = Db ()
121
+ obj = {'config_db' : db .cfgdb }
122
+
123
+ # remove vlan IP`s
124
+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
125
+ print (db .cfgdb .get_table ('INTERFACE' ))
126
+ assert ('Ethernet16.16' , '16.1.1.1/16' ) in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
127
+ assert 'Ethernet16.16' in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
128
+ result = runner .invoke (config .config .commands ["interface" ].commands ["ip" ].commands ["remove" ],
129
+ ["Ethernet16.16" , "16.1.1.1/16" ], obj = obj )
130
+ print (result .exit_code , result .output )
131
+ assert result .exit_code == 0
132
+ assert mock_run_command .call_count == 1
133
+ # removing IP should only remove the INTERFACE,IP key. The regular INTERFACE key should still exists for sub interface
134
+ assert ('Ethernet16.16' , '16.1.1.1/16' ) not in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
135
+ assert 'Ethernet16.16' in db .cfgdb .get_table ('VLAN_SUB_INTERFACE' )
136
+
137
+
108
138
class TestIntIpMultiasic (object ):
109
139
@pytest .fixture (scope = "class" , autouse = True )
110
140
def setup_class (cls ):
0 commit comments