def app():

    app = Hypr()
    app.router.add_provider(Root, "/root/<int:value>")
    app.router.add_provider(Resource, "/resource")
    app.propagate()

    return app
Exemple #2
0
def app(request):

    app = Hypr(__name__)
    app.config.from_object(request.module)

    for provider, urls in getattr(request.cls, 'providers', {}).items():

        if not isinstance(urls, tuple):
            urls = urls,

        app.router.add_provider(provider, *urls)

    app.propagate()
    return app
Exemple #3
0
def app(request):

    app = Hypr()

    for provider, urls in request.cls.providers.items():

        if isinstance(provider, str):
            provider = getattr(
                request.module,
                provider,
                type(provider, (cp_provider_factory(),), {})
            )

        if not isinstance(urls, tuple):
            urls = urls,
        app.router.add_provider(provider, *urls)

    app.propagate()
    return app
Exemple #4
0
def app(request):

    app = Hypr()

    for provider, urls in getattr(request.cls, 'providers', {}).items():

        if isinstance(provider, str):
            provider = getattr(
                request.module,
                provider,
                type(provider, (ProviderTemplate,), {})
            )

        if not isinstance(urls, tuple):
            urls = urls,

        app.router.add_provider(provider, *urls)

    app.propagate()
    return app
Exemple #5
0
def test_get_namespace():
    app = Hypr()
    app.config['FOO_OPTION_1'] = 'foo option 1'
    app.config['FOO_OPTION_2'] = 'foo option 2'
    app.config['BAR_STUFF_1'] = 'bar stuff 1'
    app.config['BAR_STUFF_2'] = 'bar stuff 2'
    foo_options = app.config.get_namespace('FOO_')
    assert 2 == len(foo_options)
    assert 'foo option 1' == foo_options['option_1']
    assert 'foo option 2' == foo_options['option_2']
    bar_options = app.config.get_namespace('BAR_', lowercase=False)
    assert 2 == len(bar_options)
    assert 'bar stuff 1' == bar_options['STUFF_1']
    assert 'bar stuff 2' == bar_options['STUFF_2']
    foo_options = app.config.get_namespace('FOO_', trim_namespace=False)
    assert 2 == len(foo_options)
    assert 'foo option 1' == foo_options['foo_option_1']
    assert 'foo option 2' == foo_options['foo_option_2']
    bar_options = app.config.get_namespace('BAR_', lowercase=False, trim_namespace=False)
    assert 2 == len(bar_options)
    assert 'bar stuff 1' == bar_options['BAR_STUFF_1']
    assert 'bar stuff 2' == bar_options['BAR_STUFF_2']