Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Port schema to 2.0.0 draft spec #107

Merged
merged 6 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions schemas/L2VPN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "L2VPN",
"type": "object",
"properties": {
"vlan_range": {
"type": "array",
"uniqueItems": true,
"items": [
{
"anyOf": [
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"type": "number"
}
]
},
{
"type": "number"
}
]
}
]
}
}
}
15 changes: 14 additions & 1 deletion schemas/Port.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@
"type": "string"
},
"nni": {
"type": "boolean"
"type": "string"
},
"services": {
"type": "object",
"properties": {
"l2vpn-ptp": {
"type": "object",
"$ref": "L2VPN.json"
},
"l2vpn-pmtp": {
"type": "object",
"$ref": "L2VPN.json"
}
}
},
"type": {
"type": "string",
Expand Down
32 changes: 32 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,38 @@ def test_port_schema(self):
self._read_schema(self.PORT_SCHEMA_FILE),
)

def test_port_schema_l2vpn_p2p(self):
jsonschema.validate(
self._read_json(TestData.PORT_FILE_L2VPN_PTP),
self._read_schema(self.PORT_SCHEMA_FILE),
)

def test_port_schema_l2vpn_p2p_invalid(self):
self.assertRaises(
json.decoder.JSONDecodeError,
self._read_json,
TestData.PORT_FILE_L2VPN_PTP_INVALID,
)

def test_port_schema_l2vpn_p2p_bad_range(self):
jsonschema.validate(
self._read_json(TestData.PORT_FILE_L2VPN_PTP_BAD_RANGE),
self._read_schema(self.PORT_SCHEMA_FILE),
)

def test_port_schema_l2vpn_p2p_ptmp(self):
jsonschema.validate(
self._read_json(TestData.PORT_FILE_L2VPN_PTP_PTMP),
self._read_schema(self.PORT_SCHEMA_FILE),
)

def test_port_schema_l2vpn_p2p_ptmp_invalid(self):
self.assertRaises(
json.decoder.JSONDecodeError,
self._read_json,
TestData.PORT_FILE_L2VPN_PTP_PTMP_INVALID,
)

def test_service_schema(self):
jsonschema.validate(
self._read_json(TestData.SERVICE_FILE),
Expand Down