def test_options_decorator(): def my_func(): ... dec = decorators.Mapping().options('/test') dec_func = dec(my_func) assert type(dec_func).__name__ == 'function'
def test_registry_components(): event = { 'resource': '/example', 'httpMethod': 'GET', } def get_example(event, context): return 'teste' routes = decorators.Mapping() r = routes.get('/example')(get_example) result = core.registry_components(event=event, routes=routes, context=None, default_response_headers=None) assert result == 'teste'
customer = fields.Str() name = fields.Str() #SERVICE def example_service(event): return core.callapi( path_param_schema=ExamplePathParam, response_schema=ExampleResponse, http_method=core.HttpMethod.GET, api_url='http://echo.jsontest.com/customer/{customer_id}/name/{name}', event=event) # ROUTES routes = decorators.Mapping() @routes.get('/example') def my_example(event, context): try: response = example_service(event) except HttpBaseException as e: return e.get_response() return HttpResponse.success(response) def lambda_handler(event, context): return core.registry_components( event=event,