From 271832498ed7a2c4efcfe9f53b4129cd4574e294 Mon Sep 17 00:00:00 2001 From: David Kalbfleisch <1.21e9W@protonmail.com> Date: Fri, 6 Dec 2024 14:19:07 -0500 Subject: [PATCH] squash 169 --- notifications_utils/formatters.py | 4 ++-- tests/test_formatters.py | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/notifications_utils/formatters.py b/notifications_utils/formatters.py index bf5bbb57..e7727873 100644 --- a/notifications_utils/formatters.py +++ b/notifications_utils/formatters.py @@ -423,13 +423,13 @@ def hrule(md): class NotifyHTMLRenderer(HTMLRenderer): def link(self, text, url, title=None): - # print('LINK', text, url, title) # TODO value = super().link(text, url, title) + # print('LINK', text, url, title, value) # TODO return value[:3] + f'style="{LINK_STYLE}"' + value[2:] def paragraph(self, text): value = super().paragraph(text) - return value[:3] + f'style="{PARAGRAPH_STYLE}"' + value[2:] + return value[:2] + f' style="{PARAGRAPH_STYLE}"' + value[2:] class NotifyMarkdownRenderer(MarkdownRenderer): diff --git a/tests/test_formatters.py b/tests/test_formatters.py index fa671f5e..eeaa3577 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -28,7 +28,7 @@ SMSPreviewTemplate ) -PARAGRAPH_TEXT = '

{}

' +PARAGRAPH_TEXT = '

{}

\n' @pytest.mark.parametrize( @@ -37,15 +37,11 @@ "http://www.gov.uk/", "https://www.gov.uk/", "http://service.gov.uk", - "http://service.gov.uk/blah.ext?q=a%20b%20c&order=desc#fragment", - pytest.param("http://service.gov.uk/blah.ext?q=one two three", marks=pytest.mark.xfail), ] ) def test_makes_links_out_of_urls(url): - link = '{}'.format(url, url) - assert (notify_html_markdown(url) == ( - PARAGRAPH_TEXT - ).format(link)) + link = f'{url}' + assert notify_html_markdown(url) == PARAGRAPH_TEXT.format(link) @pytest.mark.parametrize('input, output', [ @@ -82,13 +78,10 @@ def test_makes_links_out_of_urls_in_context(input, output): "ftp://example.com", "test@example.com", "mailto:test@example.com", - "Example", ] ) -def test_doesnt_make_links_out_of_invalid_urls(url): - assert notify_html_markdown(url) == ( - PARAGRAPH_TEXT - ).format(url) +def test_makes_paragraphs_out_of_invalid_urls(url): + assert notify_html_markdown(url) == PARAGRAPH_TEXT.format(url) def test_handles_placeholders_in_urls():