Skip to content

Commit

Permalink
test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
grybak-arista committed Oct 20, 2015
1 parent cd7432d commit 7ffbcdb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pyeapi/api/staticroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ def set_tag(self, ip_dest, next_hop, next_hop_ip=None,
"""

# Call _set_route with the new tag information
res = self._set_route(ip_dest, next_hop, next_hop_ip=next_hop_ip,
distance=distance, tag=tag,
route_name=route_name)
return res
return self._set_route(ip_dest, next_hop, next_hop_ip=next_hop_ip,
distance=distance, tag=tag,
route_name=route_name)

def set_route_name(self, ip_dest, next_hop, next_hop_ip=None,
distance=None, tag=None, route_name=None):
Expand All @@ -274,10 +273,9 @@ def set_route_name(self, ip_dest, next_hop, next_hop_ip=None,
"""

# Call _set_route with the new route_name information
res = self._set_route(ip_dest, next_hop, next_hop_ip=next_hop_ip,
distance=distance, tag=tag,
route_name=route_name)
return res
return self._set_route(ip_dest, next_hop, next_hop_ip=next_hop_ip,
distance=distance, tag=tag,
route_name=route_name)

def _build_commands(self, ip_dest, next_hop, next_hop_ip=None,
distance=None, tag=None, route_name=None):
Expand Down
34 changes: 34 additions & 0 deletions test/unit/test_api_staticroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,40 @@ def test_default(self):

self.eapi_positive_config_test(func, cmds)

def test_set_tag(self):
# Test passing in a new tag to the set_tag function
ip_dest = '1.2.3.0/24'
next_hop = 'Ethernet1'
next_hop_ip = '1.1.1.1'
distance = 10
tag = '99'

func = function('set_tag', ip_dest, next_hop,
next_hop_ip=next_hop_ip,
distance=distance, tag=tag)

cmd = "ip route %s %s %s %s tag %s" % \
(ip_dest, next_hop, next_hop_ip, distance, tag)

self.eapi_positive_config_test(func, cmd)

def test_set_route_name(self):
# Test passing in a new tag to the set_tag function
ip_dest = '1.2.3.0/24'
next_hop = 'Ethernet1'
next_hop_ip = '1.1.1.1'
distance = 10
route_name = 'test99'

func = function('set_route_name', ip_dest, next_hop,
next_hop_ip=next_hop_ip,
distance=distance, route_name=route_name)

cmd = "ip route %s %s %s %s name %s" % \
(ip_dest, next_hop, next_hop_ip, distance, route_name)

self.eapi_positive_config_test(func, cmd)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7ffbcdb

Please sign in to comment.