Skip to content

Commit

Permalink
add test fo is_valid function in Schema class
Browse files Browse the repository at this point in the history
  • Loading branch information
amsico committed Jul 4, 2022
1 parent 27fdc3c commit 7b00c3e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ def test_init_schema():
"required": ["string"]
}
schema = Schema(_def)


def test_schema_is_valid():
_def = {'type': 'object', 'properties': {'checker': {'type': 'string'}},
'schema': {'additionalProperties': False}, 'additionalProperties': False}
schema = Schema(_def)

assert schema.is_valid_data({'checker': 'a string'})
assert schema.is_valid_data({'checker': ''})

assert schema.is_valid_data({'checker': 1}) is False
assert schema.is_valid_data({'checker': 1.2}) is False

assert schema.is_valid_data({'invalid_name': 1}) is False
assert schema.is_valid_data({'invalid_name': "1"}) is False

0 comments on commit 7b00c3e

Please sign in to comment.