Skip to content

Commit

Permalink
Merge pull request #107 from atlanticwave-sdx/102.port-2.0.0-update
Browse files Browse the repository at this point in the history
Update Port schema to 2.0.0 draft spec
  • Loading branch information
sajith authored Aug 19, 2023
2 parents 29c46bf + 385d8b1 commit 1a6404a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
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

0 comments on commit 1a6404a

Please sign in to comment.