Skip to content

Commit

Permalink
Change test and fix spelling mistake
Browse files Browse the repository at this point in the history
Signed-off-by: d-dashkov <[email protected]>
  • Loading branch information
d-dashkov committed Oct 7, 2021
1 parent 8117378 commit 96079bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True):
if nh.startswith('PortChannel'):
config_db = ctx.obj['config_db']
if not nh in config_db.get_keys('PORTCHANNEL'):
ctx.fail("portchannel doest not exist.")
ctx.fail("portchannel does not exist.")
else:
ipaddress.ip_address(nh)
except ValueError:
Expand Down
22 changes: 5 additions & 17 deletions tests/static_routes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
ERROR_INVALID_IP = '''
Error: ip address is not valid.
'''
ERROR_INVALID_PORTCHANNEL = '''
Error: portchannel doest not exist.
'''


class TestStaticRoutes(object):
Expand All @@ -51,31 +54,16 @@ def test_simple_static_route(self):
print(result.exit_code, result.output)
assert not '1.2.3.4/32' in db.cfgdb.get_table('STATIC_ROUTE')

def test_portchannel_static_route(self):
def test_invalid_portchannel_static_route(self):
db = Db()
runner = CliRunner()
obj = {'config_db':db.cfgdb}

# config portchannel add PortChannel0101
result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChannel0101"], obj=obj)
print(result.exit_code, result.output)

# config route add prefix 1.2.3.4/32 nexthop PortChannel0101
result = runner.invoke(config.config.commands["route"].commands["add"], \
["prefix", "1.2.3.4/32", "nexthop", "PortChannel0101"], obj=obj)
print(result.exit_code, result.output)
assert ('1.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE')
assert db.cfgdb.get_entry('STATIC_ROUTE', '1.2.3.4/32') == {'nexthop': 'PortChannel0101', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''}

# config route del prefix 1.2.3.4/32 nexthop PortChannel0101
result = runner.invoke(config.config.commands["route"].commands["del"], \
["prefix", "1.2.3.4/32", "nexthop", "PortChannel0101"], obj=obj)
print(result.exit_code, result.output)
assert not '1.2.3.4/32' in db.cfgdb.get_table('STATIC_ROUTE')

# config portchannel del PortChannel0101
result = runner.invoke(config.config.commands["portchannel"].commands["del"], ["PortChannel0101"], obj=obj)
print(result.exit_code, result.output)
assert ERROR_INVALID_PORTCHANNEL in result.output

def test_static_route_invalid_prefix_ip(self):
db = Db()
Expand Down

0 comments on commit 96079bf

Please sign in to comment.