"""The screens that carry the rules of a recipe (points 8, 9 and 11).
The server refuses what the recipe forbids; these tests are about the operator
being told before the refusal rather than after it - a keypad that is not there,
a start button that will not start, a description that reads the way it was
written.
"""
import pytest
@pytest.fixture(autouse=True)
def _no_station(monkeypatch):
# These tests assume no station is configured (e.g. _task_list feeds the mock a
# fixed number of replies, with no /production-runs/current among them); pin it
# so a STATION_CODE left behind by an earlier test cannot change the call count (#79).
# Tests that need a station set it themselves, after this fixture has run.
monkeypatch.setattr("blueprints.measure.Config.STATION_CODE", None)
# ---------------------------------------------------------------------------
# Point 11 - line breaks and bold, and nothing else
# ---------------------------------------------------------------------------
def _render(flask_app, template_string, **context):
with flask_app.test_request_context():
return flask_app.jinja_env.from_string(template_string).render(**context)
def test_rich_text_keeps_line_breaks(flask_app):
out = _render(flask_app, "{{ v|rich_text }}", v="prima\nseconda")
assert out == "prima
seconda"
def test_rich_text_makes_bold(flask_app):
out = _render(flask_app, "{{ v|rich_text }}", v="quota **critica** qui")
assert out == "quota critica qui"
def test_rich_text_escapes_everything_else(flask_app):
"""No HTML is accepted, so there is nothing to sanitise away later."""
out = _render(flask_app, "{{ v|rich_text }}", v="")
assert "