2018-04-12 11:06:02 -07:00
|
|
|
import pytest
|
|
|
|
|
from flask import template_rendered
|
|
|
|
|
|
2025-02-14 18:40:21 -08:00
|
|
|
@pytest.mark.parametrize(('path', 'template_name'), (('/', 'fetch.html'), ('/plain', 'xhr.html'), ('/fetch', 'fetch.html'), ('/jquery', 'jquery.html')))
|
2018-04-12 11:06:02 -07:00
|
|
|
def test_index(app, client, path, template_name):
|
2025-02-14 18:40:21 -08:00
|
|
|
"""Auto-generated docstring for function test_index."""
|
|
|
|
|
|
2018-04-12 11:06:02 -07:00
|
|
|
def check(sender, template, context):
|
2025-02-14 18:40:21 -08:00
|
|
|
"""Auto-generated docstring for function check."""
|
2018-04-12 11:06:02 -07:00
|
|
|
assert template.name == template_name
|
|
|
|
|
with template_rendered.connected_to(check, app):
|
|
|
|
|
client.get(path)
|
|
|
|
|
|
2025-02-14 18:40:21 -08:00
|
|
|
@pytest.mark.parametrize(('a', 'b', 'result'), ((2, 3, 5), (2.5, 3, 5.5), (2, None, 2), (2, 'b', 2)))
|
2018-04-12 11:06:02 -07:00
|
|
|
def test_add(client, a, b, result):
|
2025-02-14 18:40:21 -08:00
|
|
|
"""Auto-generated docstring for function test_add."""
|
|
|
|
|
response = client.post('/add', data={'a': a, 'b': b})
|
|
|
|
|
assert response.get_json()['result'] == result
|