Skip to content

Commit

Permalink
additional tests for coverage; fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
grybak-arista committed Oct 20, 2015
1 parent 3e3888a commit 05111f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyeapi/api/staticroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ def _set_route(self, ip_dest, next_hop, next_hop_ip=None,


def instance(node):
"""Returns an instance of Vlans
"""Returns an instance of StaticRoute
This method will create and return an instance of the Vlans object passing
the value of API to the object. The instance method is required for the
resource to be autoloaded by the Node object
This method will create and return an instance of the StaticRoute
object passing the value of API to the object. The instance method
is required for the resource to be autoloaded by the Node object
Args:
node (Node): The node argument passes an instance of Node to the
Expand Down
27 changes: 27 additions & 0 deletions test/system/test_api_staticroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,33 @@ def test_default(self):

self.assertTrue(result)

def test_set_tag(self):
# Validate the set_tag function returns without an error
# when modifying the tag on an existing route

for dut in self.duts:
dut.config(['no ip routing delete-static-routes',
'ip routing',
'ip route 1.2.3.0/24 Ethernet1 1.1.1.1 10 tag 99'])

result = dut.api('staticroute').set_tag(
'1.2.3.0/24', 'Ethernet1', next_hop_ip='1.1.1.1',
distance=10, tag=3)
self.assertTrue(result)

def test_set_route_name(self):
# Validate the set_route_name function returns without an error
# when modifying the tag on an existing route

for dut in self.duts:
dut.config(['no ip routing delete-static-routes',
'ip routing',
'ip route 1.2.3.0/24 Ethernet1 1.1.1.1 1 name test99'])

result = dut.api('staticroute').set_route_name(
'1.2.3.0/24', 'Ethernet1', next_hop_ip='1.1.1.1',
distance=1, route_name='test3')
self.assertTrue(result)

if __name__ == '__main__':
unittest.main()
9 changes: 9 additions & 0 deletions test/unit/test_api_staticroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ def __init__(self, *args, **kwargs):
self.instance = pyeapi.api.staticroute.StaticRoute(None)
self.config = open(get_fixture('running_config.text')).read()

def test_instance(self):
result = pyeapi.api.staticroute.instance(None)
self.assertIsInstance(result, pyeapi.api.staticroute.StaticRoute)

def test_get_with_invalid_distance(self):
with self.assertRaises(ValueError):
self.instance.get('1.2.3.0/24', 'Ethernet1', 'z',
next_hop_ip='1.1.1.1')

def test_get(self):
# Test retrieval of a specific static route entry
# Assumes running_config.text file contains the ip route lines:
Expand Down

0 comments on commit 05111f7

Please sign in to comment.