1
0
mirror of https://github.com/gsi-upm/senpy synced 2025-08-23 18:12:20 +00:00

Fix schema issues and parameter validation

This commit is contained in:
J. Fernando Sánchez
2018-05-14 11:38:02 +02:00
parent 48f5ffafa1
commit 697e779767
9 changed files with 44 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ class APITest(TestCase):
query = {}
plug_params = {
'hello': {
'aliases': ['hello', 'hiya'],
'aliases': ['hiya', 'hello'],
'required': True
}
}
@@ -48,6 +48,26 @@ class APITest(TestCase):
assert 'hello' in p
assert p['hello'] == 'dlrow'
def test_parameters2(self):
in1 = {
'meaningcloud-key': 5
}
in2 = {
'apikey': 25
}
extra_params = {
"apikey": {
"aliases": [
"apikey",
"meaningcloud-key"
],
"required": True
}
}
p1 = parse_params(in1, extra_params)
p2 = parse_params(in2, extra_params)
assert (p2['apikey'] / p1['apikey']) == 5
def test_default(self):
spec = {
'hello': {

View File

@@ -8,6 +8,8 @@ from fnmatch import fnmatch
from jsonschema import RefResolver, Draft4Validator, ValidationError
from senpy.models import read_schema
root_path = path.join(path.dirname(path.realpath(__file__)), '..')
schema_folder = path.join(root_path, 'senpy', 'schemas')
examples_path = path.join(root_path, 'docs', 'examples')
@@ -15,7 +17,8 @@ bad_examples_path = path.join(root_path, 'docs', 'bad-examples')
class JSONSchemaTests(unittest.TestCase):
pass
def test_definitions(self):
read_schema('definitions.json')
def do_create_(jsfile, success):