Browse Source

Added a migrated moduleapp as blueprint app

pull/262/head
Armin Ronacher 14 years ago
parent
commit
37fab78887
  1. 7
      tests/blueprintapp/__init__.py
  2. 0
      tests/blueprintapp/apps/__init__.py
  3. 13
      tests/blueprintapp/apps/admin/__init__.py
  4. 1
      tests/blueprintapp/apps/admin/static/css/test.css
  5. 1
      tests/blueprintapp/apps/admin/static/test.txt
  6. 1
      tests/blueprintapp/apps/admin/templates/admin/index.html
  7. 8
      tests/blueprintapp/apps/frontend/__init__.py
  8. 1
      tests/blueprintapp/apps/frontend/templates/frontend/index.html
  9. 36
      tests/flask_tests.py

7
tests/blueprintapp/__init__.py

@ -0,0 +1,7 @@
from flask import Flask
app = Flask(__name__)
from moduleapp.apps.admin import admin
from moduleapp.apps.frontend import frontend
app.register_blueprint(admin)
app.register_blueprint(frontend)

0
tests/blueprintapp/apps/__init__.py

13
tests/blueprintapp/apps/admin/__init__.py

@ -0,0 +1,13 @@
from flask import Blueprint, render_template
admin = Blueprint(__name__, url_prefix='/admin')
@admin.route('/')
def index():
return render_template('admin/index.html')
@admin.route('/index2')
def index2():
return render_template('./admin/index.html')

1
tests/blueprintapp/apps/admin/static/css/test.css

@ -0,0 +1 @@
/* nested file */

1
tests/blueprintapp/apps/admin/static/test.txt

@ -0,0 +1 @@
Admin File

1
tests/blueprintapp/apps/admin/templates/admin/index.html

@ -0,0 +1 @@
Hello from the Admin

8
tests/blueprintapp/apps/frontend/__init__.py

@ -0,0 +1,8 @@
from flask import Blueprint, render_template
frontend = Blueprint(__name__)
@frontend.route('/')
def index():
return render_template('frontend/index.html')

1
tests/blueprintapp/apps/frontend/templates/frontend/index.html

@ -0,0 +1 @@
Hello from the Frontend

36
tests/flask_tests.py

@ -433,7 +433,7 @@ class BasicFunctionalityTestCase(unittest.TestCase):
def test_teardown_request_handler_debug_mode(self):
called = []
app = flask.Flask(__name__)
app.debug = True
app.testing = True
@app.teardown_request
def teardown_request(exc):
called.append(True)
@ -819,7 +819,7 @@ class JSONTestCase(unittest.TestCase):
def test_json_body_encoding(self):
app = flask.Flask(__name__)
app.debug = True
app.testing = True
@app.route('/')
def index():
return flask.request.json
@ -1139,7 +1139,7 @@ class ModuleTestCase(unittest.TestCase):
def test_templates_and_static(self):
app = moduleapp
app.debug = True
app.testing = True
c = app.test_client()
rv = c.get('/')
@ -1293,6 +1293,36 @@ class BlueprintTestCase(unittest.TestCase):
self.assertEqual(c.get('/1/bar').data, u'23')
self.assertEqual(c.get('/2/bar').data, u'19')
def test_templates_and_static(self):
from blueprintapp import app
c = app.test_client()
rv = c.get('/')
assert rv.data == 'Hello from the Frontend'
rv = c.get('/admin/')
assert rv.data == 'Hello from the Admin'
rv = c.get('/admin/index2')
assert rv.data == 'Hello from the Admin'
rv = c.get('/admin/static/test.txt')
assert rv.data.strip() == 'Admin File'
rv = c.get('/admin/static/css/test.css')
assert rv.data.strip() == '/* nested file */'
with app.test_request_context():
assert flask.url_for('admin.static', filename='test.txt') \
== '/admin/static/test.txt'
with app.test_request_context():
try:
flask.render_template('missing.html')
except TemplateNotFound, e:
assert e.name == 'missing.html'
else:
assert 0, 'expected exception'
with flask.Flask(__name__).test_request_context():
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
class SendfileTestCase(unittest.TestCase):

Loading…
Cancel
Save