Added a migrated moduleapp as blueprint app
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent e17e74d · Browse files · 9 files·+65 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+65 added−3 removed
- tests:+65 added−3 removed
Provenance
- Commit
37fab78- Tree
4675480- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
e17e74d
9 files changed+65 added−3 removed
added:tests/blueprintapp/apps/admin/static/css/test.css+1 added
1/* nested file */added:tests/blueprintapp/apps/admin/static/test.txt+1 added
1+Admin Fileadded:tests/blueprintapp/apps/admin/templates/admin/index.html+1 added
1Hello from the Adminadded:tests/blueprintapp/apps/admin/__init__.py+13 added
1+from flask import Blueprint, render_template2+3+admin = Blueprint(__name__, url_prefix='/admin')4+5+6+@admin.route('/')7+def index():8+ return render_template('admin/index.html')9+10+11+@admin.route('/index2')12+def index2():13+ return render_template('./admin/index.html')added:tests/blueprintapp/apps/frontend/templates/frontend/index.html+1 added
1Hello from the Frontendadded:tests/blueprintapp/apps/frontend/__init__.py+8 added
1+from flask import Blueprint, render_template2+3+frontend = Blueprint(__name__)4+5+6+@frontend.route('/')7+def index():8+ return render_template('frontend/index.html')added:tests/blueprintapp/apps/__init__.py
added:tests/blueprintapp/__init__.py+7 added
1+from flask import Flask2+3+app = Flask(__name__)4+from moduleapp.apps.admin import admin5+from moduleapp.apps.frontend import frontend6+app.register_blueprint(admin)7+app.register_blueprint(frontend)modified:tests/flask_tests.py+33 added-3 removed
431 unmodified lines432 433 def test_teardown_request_handler_debug_mode(self):434 called = []435 app = flask.Flask(__name__)436- app.debug = True436+ app.testing = True437 @app.teardown_request438 def teardown_request(exc):439 called.append(True)440 return "Ignored"377 unmodified lines818 class JSONTestCase(unittest.TestCase):819 820 def test_json_body_encoding(self):821 app = flask.Flask(__name__)822- app.debug = True822+ app.testing = True823 @app.route('/')824 def index():825 return flask.request.json826 311 unmodified lines1138 assert 'internal server error' == rv.data1139 1140 def test_templates_and_static(self):1141 app = moduleapp1142- app.debug = True1142+ app.testing = True1143 c = app.test_client()1144 1145 rv = c.get('/')1146 assert rv.data == 'Hello from the Frontend'145 unmodified lines1292 self.assertEqual(c.get('/2/foo').data, u'19/42')1293 self.assertEqual(c.get('/1/bar').data, u'23')1294 self.assertEqual(c.get('/2/bar').data, u'19')1295 1296+ def test_templates_and_static(self):1297+ from blueprintapp import app1298+ c = app.test_client()1299 1300+ rv = c.get('/')1301+ assert rv.data == 'Hello from the Frontend'1302+ rv = c.get('/admin/')1303+ assert rv.data == 'Hello from the Admin'1304+ rv = c.get('/admin/index2')1305+ assert rv.data == 'Hello from the Admin'1306+ rv = c.get('/admin/static/test.txt')1307+ assert rv.data.strip() == 'Admin File'1308+ rv = c.get('/admin/static/css/test.css')1309+ assert rv.data.strip() == '/* nested file */'1310+1311+ with app.test_request_context():1312+ assert flask.url_for('admin.static', filename='test.txt') \1313+ == '/admin/static/test.txt'1314+1315+ with app.test_request_context():1316+ try:1317+ flask.render_template('missing.html')1318+ except TemplateNotFound, e:1319+ assert e.name == 'missing.html'1320+ else:1321+ assert 0, 'expected exception'1322+1323+ with flask.Flask(__name__).test_request_context():1324+ assert flask.render_template('nested/nested.txt') == 'I\'m nested'1325+1326+1327 class SendfileTestCase(unittest.TestCase):1328 1329 def test_send_file_regular(self):1330 app = flask.Flask(__name__)430 unmodified lines