-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest_schema_util.py
43 lines (29 loc) · 1.32 KB
/
test_schema_util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
from inference_schema.parameter_types.standard_py_parameter_type import StandardPythonParameterType
from inference_schema.schema_decorators import input_schema, output_schema
from inference_schema.schema_util import is_schema_decorated
@input_schema('data', StandardPythonParameterType('Hello'))
def input_decorated_function(data):
return data
@output_schema(StandardPythonParameterType('Hello'))
def output_decorated_function(data):
return data
@input_schema('data', StandardPythonParameterType('Hello'))
@output_schema(StandardPythonParameterType('Hello'))
def both_decorated_function(data):
return data
def passthrough_decorator(wrapt_func):
def inner_func(*args, **kwargs):
return wrapt_func(*args, **kwargs)
return inner_func
@passthrough_decorator
def custom_decorator_function(data):
return data
class TestSchemaUtil(object):
def test_is_schema_decorated(self):
assert is_schema_decorated(input_decorated_function)
assert is_schema_decorated(output_decorated_function)
assert is_schema_decorated(both_decorated_function)
assert not is_schema_decorated(custom_decorator_function)