-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make get_versioned_release_schema more robust to bad extensions
- Loading branch information
1 parent
8d643fe
commit 628d0cb
Showing
7 changed files
with
208 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "ocdsextensionregistry" | ||
version = "0.6.7" | ||
version = "0.6.8" | ||
authors = [{name = "Open Contracting Partnership", email = "[email protected]"}] | ||
description = "Eases access to information from the extension registry of the Open Contracting Data Standard" | ||
readme = "README.rst" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ | ||
"properties": { | ||
"json_schema_example_fields": { | ||
"type": "object", | ||
"properties": { | ||
"minimum": { | ||
"minimum": 2 | ||
}, | ||
"minimum2": { | ||
"exclusiveMinimum": true, | ||
"minimum": 2 | ||
}, | ||
"maximum": { | ||
"maximum": 2 | ||
}, | ||
"maximum2": { | ||
"exclusiveMaximum": true, | ||
"maximum": 2 | ||
}, | ||
"minItems": { | ||
"type": "array", | ||
"minItems": 2 | ||
}, | ||
"maxItems": { | ||
"type": "array", | ||
"maxItems": 2 | ||
}, | ||
"minLength": { | ||
"type": "string", | ||
"minLength": 2 | ||
}, | ||
"maxLength": { | ||
"type": "string", | ||
"maxLength": 2 | ||
}, | ||
"maxProperties": { | ||
"type": "object", | ||
"maxProperties": 2 | ||
}, | ||
"multipleOf": { | ||
"type": "number", | ||
"multipleOf": 3 | ||
}, | ||
"not": { | ||
"not": { | ||
"type": "string" | ||
} | ||
}, | ||
"anyOf": { | ||
"anyOf": [ | ||
{"type": "array"}, | ||
{"type": "object"} | ||
] | ||
}, | ||
"allOf": { | ||
"anyOf": [ | ||
{"type": "array"}, | ||
{"type": "object"} | ||
] | ||
}, | ||
"oneOf": { | ||
"oneOf": [ | ||
{"type": "array"}, | ||
{"type": "object"} | ||
] | ||
}, | ||
"oneOf2": { | ||
"oneOf": [ | ||
{"type": "number"}, | ||
{"type": "integer"} | ||
] | ||
}, | ||
"additionalItems": { | ||
"type": "array", | ||
"items": [{ | ||
"type": "string" | ||
}], | ||
"additionalItems": false | ||
}, | ||
"additionalProperties": { | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"additionalProperties2": { | ||
"type": "object", | ||
"patternProperties": { | ||
"okay": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"dependencies": { | ||
"b": ["a"] | ||
} | ||
}, | ||
"format": { | ||
"type": "string", | ||
"format": "email" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
import json | ||
|
||
import json_merge_patch | ||
import pytest | ||
|
||
from ocdsextensionregistry import get_versioned_release_schema | ||
from ocdsextensionregistry.exceptions import VersionedReleaseWarning | ||
from tests import read | ||
|
||
|
||
def test_get_versioned_release_schema(): | ||
schema = json.loads(read('release-schema.json')) | ||
|
||
actual = get_versioned_release_schema(schema, '1__1__5') | ||
|
||
assert actual == json.loads(read('versioned-release-validation-schema.json')) | ||
|
||
|
||
def test_items_array(): | ||
schema = get_versioned_release_schema(json.loads(read('release-schema.json')), '1__1__5') | ||
|
||
assert schema == json.loads(read('versioned-release-validation-schema.json')) | ||
json_merge_patch.merge(schema, json.loads(read('schema-items-array.json'))) | ||
|
||
with pytest.warns(VersionedReleaseWarning) as records: | ||
get_versioned_release_schema(schema, '1__1__5') | ||
|
||
assert len(records) == 62 |