Skip to main content

Class for autotests flask python apps

Project description

Class for autotests flask python apps

GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status Codacy Badge Codacy Badge

Install

pip install tester_flask

Usage in tests

from flask import Flask
from tester_flask import TestFlask

app = Flask(__name__)


@app.route('/', methods=['GET', 'POST'])
def main_page():
    return "Flask OK"


@app.route('/redirect', methods=['POST'])
def redirect_page():
    return redirect(url_for('main_page'))


class TestFlaskApp(TestFlask):

    def setUp(self):
        super(TestFlaskApp, self).setUp()
        TestFlask.set_up(self, app)

    def test_app(self):
        assert self.simple_view('main_page').status_code == 200
        assert self.param_post('main_page', {'hello': 1}, {'one': 1}).status_code == 200

        response = self.simple_post('redirect_page', {'one': 1}, follow=False)
        assert self.final_url(response) == self.get_url('main_page')

Development

git clone git@github.com:vb64/test.helper.flask.git
cd test.helper.flask

With Python 3

make setup PYTHON_BIN="/path/to/python3
make tests

With Python 2

make setup2 PYTHON_BIN="/path/to/python2
make tests2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tester_flask-1.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

tester_flask-1.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page