from flask import Flask from werkzeug.routing import BuildError import pytest from coaster.db import db from .test_sqlalchemy_models import Container, NamedDocument, ScopedNamedDocument # --- Test setup -------------------------------------------------------------- app1 = Flask(__name__) app1.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app1.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app1) app2 = Flask(__name__) app2.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app2.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app2) @app1.route('/<doc>') @NamedDocument.is_url_for('view', doc='name') def doc_view(doc): return u'{} {}'.format('view', doc) @app1.route('/<doc>/edit') @NamedDocument.is_url_for('edit', doc='name')
from __future__ import absolute_import import unittest from werkzeug.routing import BuildError from flask import Flask from coaster.db import db from .test_models import Container, NamedDocument, ScopedNamedDocument # --- Test setup -------------------------------------------------------------- app1 = Flask(__name__) app1.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app1.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app1) app2 = Flask(__name__) app2.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app2.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app2) @app1.route('/<doc>') @NamedDocument.is_url_for('view', doc='name') def doc_view(doc): return u'{} {}'.format('view', doc) @app1.route('/<doc>/edit') @NamedDocument.is_url_for('edit', doc='name')
import unittest from flask import Flask from coaster.db import db from test_models import Container, NamedDocument, ScopedNamedDocument # --- Test setup -------------------------------------------------------------- app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' db.init_app(app) @app.route('/<doc>') @NamedDocument.is_url_for('view', doc='name') def doc_view(doc): return u'{} {}'.format('view', doc) @app.route('/<doc>/edit') @NamedDocument.is_url_for('edit', doc='name') def doc_edit(doc): return u'{} {}'.format('edit', doc) @app.route('/<doc>/upper') @NamedDocument.is_url_for('upper', doc=lambda d: d.name.upper()) def doc_upper(doc): return u'{} {}'.format('upper', doc)
import pytest from coaster.db import db from coaster.sqlalchemy import ( BaseMixin, ImmutableColumnError, UuidMixin, cached, immutable, ) app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) # --- Models ------------------------------------------------------------------ class ReferralTarget(BaseMixin, db.Model): __tablename__ = 'referral_target' class IdOnly(BaseMixin, db.Model): __tablename__ = 'id_only' __uuid_primary_key__ = False is_regular = db.Column(db.Integer) is_immutable = immutable(db.Column(db.Integer)) is_cached = cached(db.Column(db.Integer))