from flask import Flask, Blueprint
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("blueprints")
bp = Blueprint("bptest", "bptest")
BasicView.register(bp)
IndexView.register(bp)
app.register_blueprint(bp)

client = app.test_client()


def test_bp_index():
    resp = client.get("/basic/")
    eq_("Index", resp.data)


def test_bp_get():
    resp = client.get("/basic/1234")
    eq_("Get 1234", resp.data)


def test_bp_put():
    resp = client.put("/basic/1234")
    eq_("Put 1234", resp.data)


def test_bp_patch():
    resp = client.patch("/basic/1234")
    eq_("Patch 1234", resp.data)
示例#2
0
from flask import Flask, url_for
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("common")
BasicView.register(app)
IndexView.register(app)

client = app.test_client()

def test_index():
    resp = client.get("/basic/")
    eq_("Index", resp.data)

def test_get():
    resp = client.get("/basic/1234")
    eq_("Get 1234", resp.data)

def test_put():
    resp = client.put("/basic/1234")
    eq_("Put 1234", resp.data)

def test_patch():
    resp = client.patch("/basic/1234")
    eq_("Patch 1234", resp.data)

def test_post():
    resp = client.post("/basic/")
    eq_("Post", resp.data)

def test_delete():
示例#3
0
from flask import Flask, Blueprint
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("blueprints")
bp = Blueprint("bptest", "bptest")
BasicView.register(bp)
IndexView.register(bp)
app.register_blueprint(bp)

client = app.test_client()

def test_bp_index():
    resp = client.get("/basic/")
    eq_("Index", resp.data)

def test_bp_get():
    resp = client.get("/basic/1234")
    eq_("Get 1234", resp.data)

def test_bp_put():
    resp = client.put("/basic/1234")
    eq_("Put 1234", resp.data)

def test_bp_patch():
    resp = client.patch("/basic/1234")
    eq_("Patch 1234", resp.data)

def test_bp_post():
    resp = client.post("/basic/")
    eq_("Post", resp.data)
from flask import Flask, url_for
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("common")
BasicView.register(app)
IndexView.register(app)

client = app.test_client()

def test_index_url():
    with app.test_request_context():
        url = url_for("IndexView:index")
        eq_("/", url)

def test_basic_index_url():
    with app.test_request_context():
        url = url_for("BasicView:index")
        eq_("/basic/", url)

def test_custom_endpoint_url():
    with app.test_request_context():
        url = url_for("basic_endpoint")
        eq_("/basic/endpoint/", url)