mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-05 22:21:34 -04:00
Localize notification_utils to the admin
This changeset pulls in all of the notification_utils code directly into the admin 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 admin. 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