mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
Removed one more utils reference in the README and fixed directory name
Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
71
tests/notifications_utils/test_field_html_handling.py
Normal file
71
tests/notifications_utils/test_field_html_handling.py
Normal file
@@ -0,0 +1,71 @@
|
||||
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
|
||||
Reference in New Issue
Block a user