Exemplo n.º 1
0
def app(view_and_schema, app):
    UserFlumpView, _, _ = view_and_schema

    class PostOnlyView(UserFlumpView):
        HTTP_METHODS = HttpMethods.POST

    blueprint = FlumpBlueprint('post_only_blueprint', __name__)
    blueprint.register_flump_view(PostOnlyView, '/post_only/')
    app.register_blueprint(blueprint)
    return app
Exemplo n.º 2
0
def test_uses_view_name_if_present():
    blueprint = FlumpBlueprint('test_flump', __name__)
    blueprint.register_flump_view(ViewNameView, '/endpoint')

    app = Flask(__name__)

    app.register_blueprint(blueprint)

    with app.test_request_context('/'):
        assert url_for('test_flump.totally_unique_name')
Exemplo n.º 3
0
def test_custom_url_mapping():
    blueprint = FlumpBlueprint('test_flump', __name__)
    blueprint.register_flump_view(ViewWithUrlMapping, '/endpoint')

    app = Flask(__name__)

    app.register_blueprint(blueprint)

    rules = [i.rule for i in app.url_map._rules_by_endpoint['test_flump.blah']]
    assert len(rules) == 2
    assert set(rules) == {'/endpoint'}
Exemplo n.º 4
0
def test_adds_trailing_slash_to_id_specific_route_if_left_off():
    blueprint = FlumpBlueprint('test_flump', __name__)
    blueprint.register_flump_view(ViewForTest, '/endpoint')

    assert blueprint.name == 'test_flump'

    app = Flask(__name__)

    app.register_blueprint(blueprint)

    rules = [i.rule for i in app.url_map._rules_by_endpoint['test_flump.blah']]
    assert len(rules) == 5
    assert set(rules) == {'/endpoint', '/endpoint/<entity_id>'}
Exemplo n.º 5
0
def test_flump_blueprint():
    blueprint = FlumpBlueprint('test_flump', __name__)
    blueprint.register_flump_view(ViewForTest, '/endpoint/')

    assert blueprint.name == 'test_flump'

    app = Flask(__name__)

    app.register_blueprint(blueprint)

    rules = [i.rule for i in app.url_map._rules_by_endpoint['test_flump.blah']]
    assert len(rules) == 5
    assert set(rules) == {'/endpoint', '/endpoint/<entity_id>'}
Exemplo n.º 6
0
def app(view_and_schema):
    view_class, schema, _ = view_and_schema
    blueprint = FlumpBlueprint('flump', __name__)
    blueprint.register_flump_view(view_class, '/user/')

    app = Flask(__name__)
    app.response_class = FlumpTestResponse
    app.config['SERVER_NAME'] = 'localhost'
    app.config['SERVER_PROTOCOL'] = 'http'
    app.config['DEBUG'] = True
    app.config['TESTING'] = True

    app.register_blueprint(blueprint, url_prefix='/tester')

    ctx = app.app_context()
    ctx.push()
    try:
        yield app
    finally:
        ctx.pop()
Exemplo n.º 7
0
def app(view_and_schema):
    view_class, schema, _ = view_and_schema
    blueprint = FlumpBlueprint('flump', __name__)
    blueprint.register_flump_view(view_class, '/user/')

    app = Flask(__name__)
    app.response_class = FlumpTestResponse
    app.config['SERVER_NAME'] = 'localhost'
    app.config['SERVER_PROTOCOL'] = 'http'
    app.config['DEBUG'] = True
    app.config['TESTING'] = True

    app.register_blueprint(blueprint, url_prefix='/tester')

    ctx = app.app_context()
    ctx.push()
    try:
        yield app
    finally:
        ctx.pop()