mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
PR revision: test build_dict_conforming... arg for schema type
Raise an error if it's not a schema.Object instance (not just if it's not a schema.Schema instance). Also adds a test for this. Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
This commit is contained in:
parent
9aa22466c0
commit
25aa71d4c6
2 changed files with 9 additions and 2 deletions
|
|
@ -292,6 +292,13 @@ def test_build_dict_conforming_to_schema(self):
|
|||
# Test construction of a few metadata formats using
|
||||
# build_dict_conforming_to_schema().
|
||||
|
||||
# Try the wrong type of schema object.
|
||||
STRING_SCHEMA = securesystemslib.schema.AnyString()
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
tuf.formats.build_dict_conforming_to_schema(
|
||||
STRING_SCHEMA, string='some string')
|
||||
|
||||
# Try building Timestamp metadata.
|
||||
spec_version = tuf.SPECIFICATION_VERSION
|
||||
version = 8
|
||||
|
|
|
|||
|
|
@ -516,9 +516,9 @@ def build_dict_conforming_to_schema(schema, **kwargs):
|
|||
"""
|
||||
|
||||
# Check the schema argument type (must provide check_match and _required).
|
||||
if not isinstance(schema, SCHEMA.Schema):
|
||||
if not isinstance(schema, SCHEMA.Object):
|
||||
raise ValueError(
|
||||
'The first argument must be a schema.Schema object, but is not. '
|
||||
'The first argument must be a schema.Object instance, but is not. '
|
||||
'Given schema: ' + repr(schema))
|
||||
|
||||
# Make a copy of the provided fields so that the caller's provided values
|
||||
|
|
|
|||
Loading…
Reference in a new issue