Make the test.errors.count value explicit, update tests which had an implicit count

This commit is contained in:
Pim van Pelt
2022-03-20 19:44:29 +00:00
parent 1ff3ae95cc
commit e46cf3d3a8
8 changed files with 10 additions and 6 deletions

View File

@ -58,13 +58,10 @@ class YAMLTest(unittest.TestCase):
v = Validator(schema=self.yaml_schema) v = Validator(schema=self.yaml_schema)
rv, msgs = v.validate(cfg) rv, msgs = v.validate(cfg)
count = None count = 0
try: if 'test' in unittest and 'errors' in unittest['test'] and 'count' in unittest['test']['errors']:
count = unittest['test']['errors']['count'] count = unittest['test']['errors']['count']
except: assert len(msgs) == count, "%s: Expected %d error messages, got %d" % (self.yaml_filename, count, len(msgs))
pass
if isinstance(count, int):
assert len(msgs) == count, "%s: Expected %d error messages, got %d" % (self.yaml_filename, count, len(msgs))
msgs_unexpected = 0 msgs_unexpected = 0
msgs_expected = [] msgs_expected = []

View File

@ -4,6 +4,7 @@ test:
expected: expected:
- "mtu.*less than 128" - "mtu.*less than 128"
- "mtu.*greater than 9216" - "mtu.*greater than 9216"
count: 2
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,6 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* has MTU 9001 higher than parent MTU 9000" - "sub-interface .* has MTU 9001 higher than parent MTU 9000"
count: 1
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -4,6 +4,7 @@ test:
expected: expected:
- "100 .* unique encapsulation" - "100 .* unique encapsulation"
- "101 .* unique encapsulation" - "101 .* unique encapsulation"
count: 2
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,6 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* has LCP but .* does not have LCP" - "sub-interface .* has LCP but .* does not have LCP"
count: 1
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,6 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* has LCP with too long name" - "sub-interface .* has LCP with too long name"
count: 1
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,6 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* has an address but .* does not have LCP" - "sub-interface .* has an address but .* does not have LCP"
count: 1
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,6 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* has no config" - "sub-interface .* has no config"
count: 1
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0: