예제 #1
0
def test_bp_url_prefix():
    foo = Blueprint('foo', __name__)
    BasicView.register(foo, route_base="/")
    app.register_blueprint(foo, url_prefix='/foo')

    resp = client.get('/foo/')
    eq_('Index', resp.data)
예제 #2
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)
예제 #3
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():
예제 #4
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)
예제 #5
0
from flask import Flask, url_for
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("common")
app.config["SERVER_NAME"] = "test.test"
BasicView.register(app, subdomain="basic")

client = app.test_client()

def test_index_subdomain():
    resp = client.get("/basic/", base_url="http://basic.test.test")
    eq_("Index", resp.data)

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

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

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

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

def test_delete():
예제 #6
0
from flask import Flask, Blueprint
from view_classes import BasicView, SubdomainAttributeView, SubdomainRouteView
from nose.tools import *

app = Flask("blueprints")
app.config["SERVER_NAME"] = "test.test"

bp = Blueprint("bptest1", "bptest2")
SubdomainAttributeView.register(bp)
SubdomainRouteView.register(bp)
BasicView.register(bp, subdomain="sub3")

bp2 = Blueprint("bptest2", "bptest2", subdomain="sub4")
BasicView.register(bp2)

app.register_blueprint(bp)
app.register_blueprint(bp2)

client = app.test_client()

def test_bp_attr_subdomain():
    resp = client.get("/subdomainattribute/", base_url="http://sub1.test.test")
    eq_("Index", resp.data)

def test_bp_route_subdomain():
    resp = client.get("/subdomainroute/", base_url="http://sub2.test.test")
    eq_("Index", resp.data)

def test_bp_register_subdomain():
    resp = client.get("/basic/", base_url="http://sub3.test.test")
    eq_("Index", resp.data)
예제 #7
0
from flask import Flask, url_for
from view_classes import BasicView, IndexView
from nose.tools import *

app = Flask("common")
app.config["SERVER_NAME"] = "test.test"
BasicView.register(app, subdomain="basic")

client = app.test_client()


def test_index_subdomain():
    resp = client.get("/basic/", base_url="http://basic.test.test")
    eq_("Index", resp.data)


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


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


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

예제 #8
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_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)

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

app = Flask("blueprints")
app.config["SERVER_NAME"] = "test.test"

bp = Blueprint("bptest1", "bptest2")
SubdomainAttributeView.register(bp)
SubdomainRouteView.register(bp)
BasicView.register(bp, subdomain="sub3")

bp2 = Blueprint("bptest2", "bptest2", subdomain="sub4")
BasicView.register(bp2)

app.register_blueprint(bp)
app.register_blueprint(bp2)

client = app.test_client()


def test_bp_attr_subdomain():
    resp = client.get("/subdomainattribute/", base_url="http://sub1.test.test")
    eq_("Index", resp.data)


def test_bp_route_subdomain():
    resp = client.get("/subdomainroute/", base_url="http://sub2.test.test")
    eq_("Index", resp.data)