Skip to content

Commit e523615

Browse files
Adding subintf vrf bind unbind click CLI tests
1 parent 219a53d commit e523615

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/subintf_test.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,69 @@ def test_invalid_subintf_creation(self):
141141
print(result.exit_code, result.output)
142142
assert result.exit_code != 0
143143

144+
def test_subintf_vrf_bind_unbind(self):
145+
runner = CliRunner()
146+
db = Db()
147+
obj = {'db':db.cfgdb}
148+
149+
result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet0.102"], obj=obj)
150+
print(result.exit_code, result.output)
151+
assert result.exit_code == 0
152+
assert ('Ethernet0.102') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
153+
assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['admin_status'] == 'up'
154+
155+
vrf_obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}
156+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet0.102", "Vrf1"], obj=vrf_obj)
157+
assert result.exit_code == 0
158+
assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['vrf_name']
159+
160+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet0.102"], obj=vrf_obj)
161+
assert result.exit_code == 0
162+
assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']
163+
164+
result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Ethernet0.102"], obj=obj)
165+
print(result.exit_code, result.output)
166+
assert result.exit_code == 0
167+
assert ('Ethernet0.102') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
168+
169+
#shut name subintf vrf bind unbind check
170+
result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth0.1002", "2002"], obj=obj)
171+
print(result.exit_code, result.output)
172+
assert result.exit_code == 0
173+
assert ('Eth0.1002') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
174+
175+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Eth0.1002", "Vrf1"], obj=vrf_obj)
176+
assert result.exit_code == 0
177+
assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.1002']['vrf_name']
178+
179+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Eth0.1002"], obj=vrf_obj)
180+
assert result.exit_code == 0
181+
assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.1002']
182+
183+
result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Eth0.1002"], obj=obj)
184+
print(result.exit_code, result.output)
185+
assert result.exit_code == 0
186+
assert ('Eth0.1002') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
187+
188+
#Po subintf vrf bind unbind check
189+
result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Po0004.1004", "2004"], obj=obj)
190+
print(result.exit_code, result.output)
191+
assert result.exit_code == 0
192+
assert ('Po0004.1004') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
193+
194+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Po0004.1004", "Vrf1"], obj=vrf_obj)
195+
assert result.exit_code == 0
196+
assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.1004']['vrf_name']
197+
198+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Po0004.1004"], obj=vrf_obj)
199+
assert result.exit_code == 0
200+
assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.1004']
201+
202+
result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Po0004.1004"], obj=obj)
203+
print(result.exit_code, result.output)
204+
assert result.exit_code == 0
205+
assert ('Po0004.1004') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')
206+
144207
@classmethod
145208
def teardown_class(cls):
146209
os.environ['UTILITIES_UNIT_TESTING'] = "0"

0 commit comments

Comments
 (0)