|
| 1 | +# --------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# --------------------------------------------------------- |
| 4 | + |
| 5 | +from inference_schema.parameter_types.standard_py_parameter_type import StandardPythonParameterType |
| 6 | +from inference_schema.schema_decorators import input_schema, output_schema |
| 7 | +from inference_schema.schema_util import is_schema_decorated |
| 8 | + |
| 9 | + |
| 10 | +@input_schema('data', StandardPythonParameterType('Hello')) |
| 11 | +def input_decorated_function(data): |
| 12 | + return data |
| 13 | + |
| 14 | + |
| 15 | +@output_schema(StandardPythonParameterType('Hello')) |
| 16 | +def output_decorated_function(data): |
| 17 | + return data |
| 18 | + |
| 19 | + |
| 20 | +@input_schema('data', StandardPythonParameterType('Hello')) |
| 21 | +@output_schema(StandardPythonParameterType('Hello')) |
| 22 | +def both_decorated_function(data): |
| 23 | + return data |
| 24 | + |
| 25 | + |
| 26 | +def passthrough_decorator(wrapt_func): |
| 27 | + def inner_func(*args, **kwargs): |
| 28 | + return wrapt_func(*args, **kwargs) |
| 29 | + return inner_func |
| 30 | + |
| 31 | + |
| 32 | +@passthrough_decorator |
| 33 | +def custom_decorator_function(data): |
| 34 | + return data |
| 35 | + |
| 36 | + |
| 37 | +class TestSchemaUtil(object): |
| 38 | + |
| 39 | + def test_is_schema_decorated(self): |
| 40 | + assert is_schema_decorated(input_decorated_function) |
| 41 | + assert is_schema_decorated(output_decorated_function) |
| 42 | + assert is_schema_decorated(both_decorated_function) |
| 43 | + assert not is_schema_decorated(custom_decorator_function) |
0 commit comments