testing.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:apimas 作者: grnet 项目源码 文件源码
def apimas_context(urlconf_module, spec):
    """
    This function (decorator) is used to customize `TestCase` classes based
    on the `APIMAS` spec of an application.

    More specifically, the given spec is used in order `Django` urls to be
    created and then test functions (triggering test case scenarios for
    every collection and action) are created and bound to the provided
    `TestCase` class.

    :param urlconf_module: Path to the module where generated django urls
    will be added.
    :param spec: `APIMAS` specification.
    """

    def wrapper(cls):
        setattr(cls, 'spec', spec)
        adapter = DjangoRestAdapter()
        adapter.construct(spec)
        setattr(cls, 'adapter', adapter)
        urls = adapter.urls.values()
        _add_urlpatterns(urlconf_module, urls)
        _add_test_functions(cls, adapter, spec)
        return override_settings(ROOT_URLCONF=urlconf_module)(cls)
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号