Skip to content

Commit

Permalink
Test to find missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ogenstad committed Oct 26, 2016
1 parent a1777eb commit 272149a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_testcases_exists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""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'
]


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'

0 comments on commit 272149a

Please sign in to comment.