[constants] add lib "schema" Schemas for all items
This commit is contained in:
parent
24bd3f5653
commit
c9639ddbc0
|
@ -1 +1,27 @@
|
||||||
|
from schema import Schema, Optional
|
||||||
|
|
||||||
VERBS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
|
VERBS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
|
||||||
|
|
||||||
|
ACLS_SCHEMA = Schema([{
|
||||||
|
'acl': str,
|
||||||
|
Optional('args'): {
|
||||||
|
Optional('required'): { str },
|
||||||
|
Optional('optional'): { str }
|
||||||
|
},
|
||||||
|
Optional('out'): { str }
|
||||||
|
}])
|
||||||
|
|
||||||
|
ROUTE_SCHEMA = Schema({
|
||||||
|
str: {
|
||||||
|
'docs': lambda n: True, # Should validate an openAPI spec
|
||||||
|
'acls': ACLS_SCHEMA
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
DOMAIN_SCHEMA = Schema({
|
||||||
|
str: ROUTE_SCHEMA
|
||||||
|
})
|
||||||
|
|
||||||
|
API_SCHEMA = Schema({
|
||||||
|
str: DOMAIN_SCHEMA # key: domain name, value: result of lib.routes.api_routes(domain_module)
|
||||||
|
})
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
from schema import Schema
|
||||||
|
def test_constants():
|
||||||
|
from halfapi.lib.constants import (
|
||||||
|
VERBS,
|
||||||
|
ACLS_SCHEMA,
|
||||||
|
ROUTE_SCHEMA,
|
||||||
|
DOMAIN_SCHEMA,
|
||||||
|
API_SCHEMA)
|
||||||
|
|
||||||
|
assert isinstance(VERBS, tuple)
|
||||||
|
assert isinstance(ACLS_SCHEMA, Schema)
|
||||||
|
assert isinstance(ROUTE_SCHEMA, Schema)
|
||||||
|
assert isinstance(DOMAIN_SCHEMA, Schema)
|
||||||
|
assert isinstance(API_SCHEMA, Schema)
|
Loading…
Reference in New Issue