I was able to do this For example, play with UserAgent
Or rather, it's just like this http://stackoverflow.com/questions/15278285/setting-mocking-request-headers-for-flask-app-unit-test
tests.py
# -*- coding: utf-8 -*-
from nose.tools import ok_, eq_
import flask
class ClientProxy(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
environ['HTTP_USER_AGENT'] = environ.get('HTTP_USER_AGENT', 'hogehoge')
return self.app(environ, start_response)
def sample_test():
app = flask.Flask(__name__)
app.wsgi_app = ClientProxy(app.wsgi_app)
with app.test_client() as c:
c.get('/')
eq_(flask.request.user_agent.string, 'hogehoge')