Check for fields that are of the wrong type. Fix bug in ip_interface() validator thanks to this unittest
This commit is contained in:
18
unittest/error-schema-field2.yaml
Normal file
18
unittest/error-schema-field2.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
test:
|
||||||
|
description: "A bunch of schema fields with the wrong type"
|
||||||
|
errors:
|
||||||
|
expected:
|
||||||
|
- "yamale: .* is not a "
|
||||||
|
count: 9
|
||||||
|
---
|
||||||
|
interfaces:
|
||||||
|
GigabitEthernet1/0/0:
|
||||||
|
description: 1234
|
||||||
|
lcp: True
|
||||||
|
mac: "0001.0203.0405"
|
||||||
|
addresses: [ 1234, "hello world", 192.0.2.1, 2001:db8::1 ]
|
||||||
|
sub-interfaces:
|
||||||
|
100:
|
||||||
|
description: [ "a", "list" ]
|
||||||
|
encapsulation:
|
||||||
|
dot1q: "hello world"
|
@ -33,6 +33,8 @@ class IPInterfaceWithPrefixLength(Validator):
|
|||||||
network = ipaddress.ip_interface(value)
|
network = ipaddress.ip_interface(value)
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
if not isinstance(value, str):
|
||||||
|
return False
|
||||||
if not '/' in value:
|
if not '/' in value:
|
||||||
return False
|
return False
|
||||||
e = value.split('/')
|
e = value.split('/')
|
||||||
|
Reference in New Issue
Block a user