mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-09 10:54:11 -04:00
This changeset copies everything in notifications_utils to turn into a local project module. It includes dependency changes to account for this adjustment and the notifications_utils tests. It also fixes all of the import statements. 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
|