def test_follow_short(self): app = flask.Flask(__name__) url = "http://www.google.com" with app.test_request_context("/shorten", data=dict(fullurl=url)): app.preprocess_request() rv = app.get("/ZMSZ0", follow_redirects=True) print rv.data
def test_follow_short(self): app = flask.Flask(__name__) url = 'http://www.google.com' with app.test_request_context('/shorten', data=dict( fullurl=url )): app.preprocess_request() rv = app.get('/ZMSZ0', follow_redirects=True) print rv.data
# -*- coding: utf-8 -*- from {{ cookiecutter.repo_name }} import app app.ready(worker=False) def load_module_recursively(module): import pkgutil for loader, name, ispkg in pkgutil.iter_modules(module.__path__): module_name = '%s.%s' % (module.__name__, name) print('loading view: %s' % module_name) _module = __import__(module_name, fromlist=['']) if ispkg: load_module_recursively(_module) from {{ cookiecutter.repo_name }} import views load_module_recursively(views) app.test_request_context().push() app.build_assets()
def test_index(self): with app.test_request_context(): session['username'] = 0 self.assertEqual(index(),render_template('index.html',uname = session['username']))
def test_howto(self): with app.test_request_context(): self.assertEqual(howto(),render_template("howto.html"))
def test_timeline(self): with app.test_request_context(): self.assertEqual(timeline(),render_template("timeline.html"))
def test_hello(self): with app.test_request_context(): self.assertEqual(hello(),render_template("login.html"))