mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-31 03:38:57 -04:00
This changeset pulls in all of the notification_utils code directly into the API and removes it as an external dependency. We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the API. Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
import pytest
|
|
|
|
from notifications_utils.field import Field
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"content, values, expected_stripped, expected_escaped, expected_passthrough",
|
|
[
|
|
(
|
|
"string <em>with</em> html",
|
|
{},
|
|
"string with html",
|
|
"string <em>with</em> html",
|
|
"string <em>with</em> html",
|
|
),
|
|
(
|
|
"string ((<em>with</em>)) html",
|
|
{},
|
|
"string <span class='placeholder'>((with))</span> html",
|
|
"string <span class='placeholder'>((<em>with</em>))</span> html",
|
|
"string <span class='placeholder'>((<em>with</em>))</span> html",
|
|
),
|
|
(
|
|
"string ((placeholder)) html",
|
|
{"placeholder": "<em>without</em>"},
|
|
"string without html",
|
|
"string <em>without</em> html",
|
|
"string <em>without</em> html",
|
|
),
|
|
(
|
|
"string ((<em>conditional</em>??<em>placeholder</em>)) html",
|
|
{},
|
|
"string <span class='placeholder-conditional'>((conditional??</span>placeholder)) html",
|
|
(
|
|
"string "
|
|
"<span class='placeholder-conditional'>"
|
|
"((<em>conditional</em>??</span>"
|
|
"<em>placeholder</em>)) "
|
|
"html"
|
|
),
|
|
(
|
|
"string "
|
|
"<span class='placeholder-conditional'>"
|
|
"((<em>conditional</em>??</span>"
|
|
"<em>placeholder</em>)) "
|
|
"html"
|
|
),
|
|
),
|
|
(
|
|
"string ((conditional??<em>placeholder</em>)) html",
|
|
{"conditional": True},
|
|
"string placeholder html",
|
|
"string <em>placeholder</em> html",
|
|
"string <em>placeholder</em> html",
|
|
),
|
|
(
|
|
"string & entity",
|
|
{},
|
|
"string & entity",
|
|
"string & entity",
|
|
"string & entity",
|
|
),
|
|
],
|
|
)
|
|
def test_field_handles_html(
|
|
content, values, expected_stripped, expected_escaped, expected_passthrough
|
|
):
|
|
assert str(Field(content, values)) == expected_stripped
|
|
assert str(Field(content, values, html="strip")) == expected_stripped
|
|
assert str(Field(content, values, html="escape")) == expected_escaped
|
|
assert str(Field(content, values, html="passthrough")) == expected_passthrough
|