This repository has been archived by the owner on Jan 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
1,964 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
future | ||
coveralls | ||
pytest | ||
pytest-cov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Test fixtures.""" | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
from builtins import super | ||
|
||
import pytest | ||
from napalm_base.test import conftest as parent_conftest | ||
|
||
from napalm_base.test.double import BaseTestDouble | ||
from napalm_base.utils import py23_compat | ||
|
||
from napalm_ios import ios | ||
|
||
|
||
@pytest.fixture(scope='class') | ||
def set_device_parameters(request): | ||
"""Set up the class.""" | ||
def fin(): | ||
request.cls.device.close() | ||
request.addfinalizer(fin) | ||
|
||
request.cls.driver = ios.IOSDriver | ||
request.cls.patched_driver = PatchedIOSDriver | ||
request.cls.vendor = 'ios' | ||
parent_conftest.set_device_parameters(request) | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
"""Generate test cases dynamically.""" | ||
parent_conftest.pytest_generate_tests(metafunc, __file__) | ||
|
||
|
||
class PatchedIOSDriver(ios.IOSDriver): | ||
"""Patched IOS Driver.""" | ||
|
||
def __init__(self, hostname, username, password, timeout=60, optional_args=None): | ||
|
||
super().__init__(hostname, username, password, timeout, optional_args) | ||
|
||
self.patched_attrs = ['device'] | ||
self.device = FakeIOSDevice() | ||
|
||
def disconnect(self): | ||
pass | ||
|
||
def is_alive(self): | ||
return { | ||
'is_alive': True # In testing everything works.. | ||
} | ||
|
||
def open(self): | ||
pass | ||
|
||
|
||
class FakeIOSDevice(BaseTestDouble): | ||
"""IOS device test double.""" | ||
|
||
def send_command(self, command): | ||
filename = '{}.txt'.format(self.sanitize_text(command)) | ||
full_path = self.find_file(filename) | ||
result = self.read_txt_file(full_path) | ||
return py23_compat.text_type(result) | ||
|
||
def disconnect(self): | ||
pass |
41 changes: 41 additions & 0 deletions
41
test/unit/mocked_data/test_get_arp_table/normal/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[{ | ||
"interface": "Vlan20", | ||
"ip": "172.29.50.1", | ||
"mac": "84b8.0276.ac0e", | ||
"age": 8.0 | ||
}, { | ||
"interface": "Vlan20", | ||
"ip": "172.29.50.2", | ||
"mac": "0019.0725.344a", | ||
"age": 221.0 | ||
}, { | ||
"interface": "Vlan20", | ||
"ip": "172.29.50.3", | ||
"mac": "0024.f7dd.7741", | ||
"age": 0.0 | ||
}, { | ||
"interface": "Vlan20", | ||
"ip": "172.29.50.10", | ||
"mac": "6805.ca12.71c2", | ||
"age": 37.0 | ||
}, { | ||
"interface": "Vlan41", | ||
"ip": "172.29.52.33", | ||
"mac": "84b8.0276.ac0e", | ||
"age": 61.0 | ||
}, { | ||
"interface": "Vlan41", | ||
"ip": "172.29.52.34", | ||
"mac": "0024.f7dd.7743", | ||
"age": 0.0 | ||
}, { | ||
"interface": "Vlan41", | ||
"ip": "172.29.52.40", | ||
"mac": "a099.9b1c.dfa7", | ||
"age": 3.0 | ||
}, { | ||
"interface": "Vlan41", | ||
"ip": "192.168.81.34", | ||
"mac": "0024.f7dd.7743", | ||
"age": 0.0 | ||
}] |
9 changes: 9 additions & 0 deletions
9
test/unit/mocked_data/test_get_arp_table/normal/show_arp___exclude_Incomplete.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Protocol Address Age (min) Hardware Addr Type Interface | ||
Internet 172.29.50.1 8 84b8.0276.ac0e ARPA Vlan20 | ||
Internet 172.29.50.2 221 0019.0725.344a ARPA Vlan20 | ||
Internet 172.29.50.3 - 0024.f7dd.7741 ARPA Vlan20 | ||
Internet 172.29.50.10 37 6805.ca12.71c2 ARPA Vlan20 | ||
Internet 172.29.52.33 61 84b8.0276.ac0e ARPA Vlan41 | ||
Internet 172.29.52.34 - 0024.f7dd.7743 ARPA Vlan41 | ||
Internet 172.29.52.40 3 a099.9b1c.dfa7 ARPA Vlan41 | ||
Internet 192.168.81.34 - 0024.f7dd.7743 ARPA Vlan41 |
1 change: 1 addition & 0 deletions
1
test/unit/mocked_data/test_get_bgp_neighbors/normal/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"global": {"router_id": "192.168.0.1", "peers": {"192.168.0.2": {"is_enabled": true, "uptime": -1, "remote_as": 65001, "description": "", "remote_id": "0.0.0.0", "local_as": 65000, "is_up": false, "address_family": {"ipv4": {"sent_prefixes": 0, "accepted_prefixes": 0, "received_prefixes": 0} }}, "192.168.0.3": {"is_enabled": true, "uptime": -1, "remote_as": 65010, "description": "", "remote_id": "192.168.0.3", "local_as": 65000, "is_up": false, "address_family": {"ipv4": {"sent_prefixes": 0, "accepted_prefixes": 0, "received_prefixes": 0} }}}}} |
1 change: 1 addition & 0 deletions
1
...est_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_2___inc_Prefixes_Current.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Prefixes Current: 0 0 |
1 change: 1 addition & 0 deletions
1
..._data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_2___inc_router_ID.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BGP version 4, remote router ID 0.0.0.0 |
2 changes: 2 additions & 0 deletions
2
...est_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_2___section_Local_Policy.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Local Policy Denied Prefixes: -------- ------- | ||
Total: 0 0 |
1 change: 1 addition & 0 deletions
1
...est_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_3___inc_Prefixes_Current.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Prefixes Current: 0 0 |
1 change: 1 addition & 0 deletions
1
..._data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_3___inc_router_ID.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BGP version 4, remote router ID 192.168.0.3 |
2 changes: 2 additions & 0 deletions
2
...est_get_bgp_neighbors/normal/show_ip_bgp_neighbors_192_168_0_3___section_Local_Policy.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Local Policy Denied Prefixes: -------- ------- | ||
Total: 0 0 |
6 changes: 6 additions & 0 deletions
6
test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BGP router identifier 192.168.0.1, local AS number 65000 | ||
BGP table version is 1, main routing table version 1 | ||
|
||
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd | ||
192.168.0.2 4 65001 0 0 1 0 0 never Idle | ||
192.168.0.3 4 65010 0 0 1 0 0 never Active |
3 changes: 3 additions & 0 deletions
3
test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary___begin_Neighbor.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd | ||
192.168.0.2 4 65001 0 0 1 0 0 never Idle | ||
192.168.0.3 4 65010 0 0 1 0 0 never Active |
5 changes: 5 additions & 0 deletions
5
test/unit/mocked_data/test_get_config/normal/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"startup": "!\n! Last configuration change at 18:41:02 UTC Thu Nov 24 2016\n!\nversion 15.5\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nno platform punt-keepalive disable-kernel-core\nplatform console auto\n!\nhostname CSR1\n!\nboot-start-marker\nboot-end-marker\n!\n!\nenable password cisco\n!\naaa new-model\n!\n!\naaa authentication login default local\naaa authorization exec default local\n!\n!\n!\n!\n!\naaa session-id common\n!\nip vrf MGMT\n!\n!\n!\n!\n!\n!\n!\n!\n!\n\n\nip domain name example.local\n\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\nsubscriber templating\n!\nmultilink bundle-name authenticated\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\nlicense udi pid CSR1000V sn 9OSEGKJXRHE\nspanning-tree extend system-id\n!\nusername cisco privilege 15 password 0 cisco\n!\nredundancy\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\ninterface Loopback0\n ip address 1.1.1.1 255.255.255.255\n!\ninterface GigabitEthernet1\n ip vrf forwarding MGMT\n ip address 192.168.35.121 255.255.255.0\n negotiation auto\n!\ninterface GigabitEthernet2\n ip address 10.1.1.1 255.255.255.0\n negotiation auto\n!\ninterface GigabitEthernet3\n no ip address\n shutdown\n negotiation auto\n!\nrouter ospf 1\n redistribute connected subnets\n network 10.1.1.0 0.0.0.255 area 0\n!\n!\nvirtual-service csr_mgmt\n!\nip forward-protocol nd\n!\nno ip http server\nno ip http secure-server\n!\n!\n!\n!\n!\n!\ncontrol-plane\n!\n !\n !\n !\n !\n!\n!\n!\n!\n!\nline con 0\nline vty 0 4\n!\n!\nend", | ||
"running": "Building configuration...\n\nCurrent configuration : 1366 bytes\n!\n! Last configuration change at 18:41:02 UTC Thu Nov 24 2016\n!\nversion 15.5\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nno platform punt-keepalive disable-kernel-core\nplatform console auto\n!\nhostname CSR1\n!\nboot-start-marker\nboot-end-marker\n!\n!\nenable password cisco\n!\naaa new-model\n!\n!\naaa authentication login default local\naaa authorization exec default local\n!\n!\n!\n!\n!\naaa session-id common\n!\nip vrf MGMT\n!\n!\n!\n!\n!\n!\n!\n!\n!\n\n\nip domain name example.local\n\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\nsubscriber templating\n!\nmultilink bundle-name authenticated\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\nlicense udi pid CSR1000V sn 9OSEGKJXRHE\nspanning-tree extend system-id\n!\nusername cisco privilege 15 password 0 cisco\n!\nredundancy\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\n!\ninterface Loopback0\n ip address 1.1.1.1 255.255.255.255\n!\ninterface GigabitEthernet1\n ip vrf forwarding MGMT\n ip address 192.168.35.121 255.255.255.0\n negotiation auto\n!\ninterface GigabitEthernet2\n ip address 10.1.1.1 255.255.255.0\n negotiation auto\n!\ninterface GigabitEthernet3\n no ip address\n shutdown\n negotiation auto\n!\nrouter ospf 1\n redistribute connected subnets\n network 10.1.1.0 0.0.0.255 area 0\n!\n!\nvirtual-service csr_mgmt\n!\nip forward-protocol nd\n!\nno ip http server\nno ip http secure-server\n!\n!\n!\n!\n!\n!\ncontrol-plane\n!\n !\n !\n !\n !\n!\n!\n!\n!\n!\nline con 0\nline vty 0 4\n!\n!\nend", | ||
"candidate": "" | ||
} |
151 changes: 151 additions & 0 deletions
151
test/unit/mocked_data/test_get_config/normal/show_running_config.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
Building configuration... | ||
|
||
Current configuration : 1366 bytes | ||
! | ||
! Last configuration change at 18:41:02 UTC Thu Nov 24 2016 | ||
! | ||
version 15.5 | ||
service timestamps debug datetime msec | ||
service timestamps log datetime msec | ||
no platform punt-keepalive disable-kernel-core | ||
platform console auto | ||
! | ||
hostname CSR1 | ||
! | ||
boot-start-marker | ||
boot-end-marker | ||
! | ||
! | ||
enable password cisco | ||
! | ||
aaa new-model | ||
! | ||
! | ||
aaa authentication login default local | ||
aaa authorization exec default local | ||
! | ||
! | ||
! | ||
! | ||
! | ||
aaa session-id common | ||
! | ||
ip vrf MGMT | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
|
||
|
||
ip domain name example.local | ||
|
||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
subscriber templating | ||
! | ||
multilink bundle-name authenticated | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
license udi pid CSR1000V sn 9OSEGKJXRHE | ||
spanning-tree extend system-id | ||
! | ||
username cisco privilege 15 password 0 cisco | ||
! | ||
redundancy | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
interface Loopback0 | ||
ip address 1.1.1.1 255.255.255.255 | ||
! | ||
interface GigabitEthernet1 | ||
ip vrf forwarding MGMT | ||
ip address 192.168.35.121 255.255.255.0 | ||
negotiation auto | ||
! | ||
interface GigabitEthernet2 | ||
ip address 10.1.1.1 255.255.255.0 | ||
negotiation auto | ||
! | ||
interface GigabitEthernet3 | ||
no ip address | ||
shutdown | ||
negotiation auto | ||
! | ||
router ospf 1 | ||
redistribute connected subnets | ||
network 10.1.1.0 0.0.0.255 area 0 | ||
! | ||
! | ||
virtual-service csr_mgmt | ||
! | ||
ip forward-protocol nd | ||
! | ||
no ip http server | ||
no ip http secure-server | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
control-plane | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
! | ||
line con 0 | ||
line vty 0 4 | ||
! | ||
! | ||
end |
Oops, something went wrong.