-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test with pytest from tox instead of using Ansible
- Loading branch information
Showing
27 changed files
with
115 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ dist/ | |
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
#lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
|
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
File renamed without changes.
File renamed without changes.
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 @@ | ||
../../templates |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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 @@ | ||
brocade_netiron_show_monitor_actual.template |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
"""tests.""" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
tests/cisco_ios/show_ip_ospf_neighbor/four_neighbors.parsed
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,30 @@ | ||
--- | ||
parsed_sample: | ||
|
||
- neighbor_id: '10.190.30.2' | ||
priority: '1' | ||
state: 'FULL/BDR' | ||
dead_time: '00:00:04' | ||
address: '10.190.16.11' | ||
interface: 'GigabitEthernet0/2.101' | ||
|
||
- neighbor_id: '10.190.30.3' | ||
priority: '1' | ||
state: 'FULL/DR' | ||
dead_time: '00:00:04' | ||
address: '10.190.16.12' | ||
interface: 'GigabitEthernet0/2.101' | ||
|
||
- neighbor_id: '10.190.30.2' | ||
priority: '1' | ||
state: 'FULL/BDR' | ||
dead_time: '00:00:04' | ||
address: '10.190.16.3' | ||
interface: 'GigabitEthernet0/2.100' | ||
|
||
- neighbor_id: '10.190.30.3' | ||
priority: '1' | ||
state: 'FULL/DR' | ||
dead_time: '00:00:04' | ||
address: '10.190.16.4' | ||
interface: 'GigabitEthernet0/2.100' |
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 @@ | ||
Neighbor ID Pri State Dead Time Address Interface | ||
10.190.30.2 1 FULL/BDR 00:00:04 10.190.16.11 GigabitEthernet0/2.101 | ||
10.190.30.3 1 FULL/DR 00:00:04 10.190.16.12 GigabitEthernet0/2.101 | ||
10.190.30.2 1 FULL/BDR 00:00:04 10.190.16.3 GigabitEthernet0/2.100 | ||
10.190.30.3 1 FULL/DR 00:00:04 10.190.16.4 GigabitEthernet0/2.100 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
"""Helper functions for testing.""" | ||
import glob | ||
|
||
|
||
def return_test_files(): | ||
"""Return a list of all the *.raw files to run tests against.""" | ||
platform_dirs = glob.glob('tests/*') | ||
|
||
platforms = [] | ||
for platform in platform_dirs: | ||
platforms.append(glob.glob('%s/*' % platform)) | ||
|
||
template_dirs = [item for sublist in platforms for item in sublist] | ||
|
||
test_commands = [] | ||
for template_dir in template_dirs: | ||
test_commands.append(glob.glob('%s/*.raw' % template_dir)) | ||
|
||
return [item for sublist in test_commands for item in sublist] |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Ensure that testcases exist for all templates.""" | ||
import csv | ||
import glob | ||
import os | ||
|
||
from ntc_templates.parse import _get_template_dir | ||
|
||
KNOWN_MISSING_TESTS = [ | ||
'cisco_ios_show_vlan', | ||
'cisco_nxos_show_interface_brief', | ||
'cisco_nxos_show_ip_ospf_neighbor_vrf', | ||
'cisco_xr_show_controllers', | ||
'.*vyos.*_os_show_interfaces', | ||
'.*vyos.*_os_show_arp', | ||
] | ||
|
||
|
||
def load_indexdata(): | ||
"""Load data from index file.""" | ||
index_data = [] | ||
with open('%s%sindex' % (_get_template_dir(), os.sep)) as indexfs: | ||
data = csv.reader(indexfs) | ||
for row in data: | ||
if len(row) > 2 and row[0] != 'Template': | ||
index_data.append(row) | ||
return index_data | ||
|
||
|
||
def test_verify_parsed_and_reference_data_exists(): | ||
"""Verify that at least one test exists for all entries in the index file.""" | ||
index = sorted(load_indexdata()) | ||
coverage = {} | ||
for row in index: | ||
template = row[0].strip() | ||
platform = row[2].strip() | ||
cut = len(platform) + 1 | ||
command = template[cut:].split('.')[0] | ||
cases = 'tests/%s/%s/*.raw' % (platform, command) | ||
test_list = glob.glob(cases) | ||
coverage['%s_%s' % (platform, command)] = len(test_list) | ||
|
||
for test in coverage: | ||
if coverage[test] == 0 and test not in KNOWN_MISSING_TESTS: | ||
assert test == 'No test cases found' |
File renamed without changes.
File renamed without changes.
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