How to use the cornice.util.func_name function in cornice

To help you get started, we’ve selected a few cornice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cornices / cornice / tests / test_pyramidhook.py View on Github external
def test_func_name_class_method(self):
        self.assertEqual("TestServiceWithWrapper.test_wrapped", func_name(TestServiceWithWrapper.test_wrapped))
github Cornices / cornice / tests / test_pyramidhook.py View on Github external
def test_func_name_undecorated_function(self):
        self.assertEqual("my_acl", func_name(my_acl))
github Cornices / cornice / tests / test_service.py View on Github external
def test_decorate_view(self):
        def myfunction():
            pass

        meth = 'POST'
        decorated = decorate_view(myfunction, {}, meth)
        self.assertEqual(decorated.__name__, "{0}__{1}".format(
            func_name(myfunction), meth))
github Cornices / cornice / tests / test_pyramidhook.py View on Github external
def test_func_name_string(self):
        self.assertEqual("some_string", func_name("some_string"))
github Cornices / cornice / tests / test_pyramidhook.py View on Github external
def test_func_name_decorated_function(self):
        self.assertEqual("return_foo", func_name(return_foo))
github Cornices / cornice / tests / test_service.py View on Github external
def test_decorate_resource_view(self):
        class MyResource(object):
            def __init__(self, **kwargs):
                pass

            def myview(self):
                pass

        meth = 'POST'
        decorated = decorate_view(_UnboundView(MyResource, 'myview'), {}, meth)
        self.assertEqual(decorated.__name__, "{0}__{1}".format(
            func_name(MyResource.myview), meth))
github Cornices / cornice / cornice / service.py View on Github external
request.info['cors_checked'] = False

        # We can't apply filters at this level, since "response" may not have
        # been rendered into a proper Response object yet.  Instead, give the
        # request a reference to its api_kwargs so that a tween can apply them.
        # We also pass the object we created (if any) so we can use it to find
        # the filters that are in fact methods.
        request.cornice_args = (args, ob)
        return response

    # return the wrapper, not the function, keep the same signature
    if not is_string(view):
        functools.update_wrapper(wrapper, view)

    # Set the wrapper name to something useful
    wrapper.__name__ = "{0}__{1}".format(func_name(view), method)
    return wrapper
github Cornices / cornice / cornice / service.py View on Github external
def __init__(self, klass, view):
        self.unbound_view = getattr(klass, view.lower())
        functools.update_wrapper(self, self.unbound_view)
        self.__name__ = func_name(self.unbound_view)