Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#199 Markdown specification (part 2 of 2) #214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

kalbfled
Copy link
Member

@kalbfled kalbfled commented Mar 7, 2025

Description

These changes add more files to the tests/test_files/ subfolders to codify the expected behavior when rendering markdown as HTML or plain text, and they implement unit tests for all the test_files/ files. The new test files focus on personalization substitutions into links and block quotes, including the substitution of lists into the latter.

Substitutions into URLs of text containing spaces should be URL-safe encoded. The goal isn't that the link is valid (that's on the user); it's that the visual presentation is correct.

The unit tests include a simple happy path test and a test for missing personalization fields, both using markdown for a paragraph. I did not exhaustively test placeholders in all the various markdown permutations we might encounter because I don't think that would add value. When the tests I actually created for the hard cases pass, I am confident the functionality will work for the more straight-forward cases.

You might note that the 3 test classes I created are repetitive. Each class tests one input markdown file. With additional parametrization, I could roll all of these classes into a single test, but I rejected that implementation in favor of only loading the input files once, via a class-scoped fixture.

issue #199

How Has This Been Tested?

I ran the unit tests. There isn't more to do for this ticket. The new tests are all skipped, the associated features are not fully implemented, and there are no changes required in notification-api.

Checklist

  • I have assigned myself to this PR
  • PR has an appropriate title: #9999 - What the thing does
  • PR has a detailed description, including links to specific documentation
  • I have added the appropriate labels to the PR.
  • I did not remove any parts of the template, such as checkboxes even if they are not used
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to any documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works. Testing guidelines
  • I have ensured the latest main is merged into my branch and all checks are green prior to review
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • The ticket was moved into the DEV test column when I began testing this change

@kalbfled kalbfled self-assigned this Mar 7, 2025
@kalbfled kalbfled marked this pull request as ready for review March 7, 2025 17:27
Substitute personalization values into markdown, and return the markdown as HTML or plain text.
"""

# TODO - Perform substitutions in the markdown. Raise ValueError for missing fields.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a ticket number on this TODO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

if html_content is None and plain_text_content is None:
raise ValueError('You must supply one of these parameters.')

# TODO - Perform substitutions in the subject. Raise ValueError for missing fields.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More TODOs - Do we need a ticket number

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link

@cris-oddball cris-oddball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be more, but I need to switch over to testing another ticket.

Comment on lines 6 to 13
# TODO - Perform substitutions in the markdown. Raise ValueError for missing fields.

if as_html:
# TODO - pass the markdown to the HTML renderer
pass
else:
# TODO - pass the markdown to the plain text renderer
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs require ticket numbers, please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

raise NotImplementedError


# TODO - The signature and return type might change after #213, during integration with notifcation-api.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO needs a ticket # please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment on lines +24 to +30
"""
In addition to the content body, e-mail notifications might have personalization values in the
subject line, and the content body might be plugged into a Jinja2 template.

The two "content" parameters generally are the output of render_notify_markdown (above).

returns: A 2-tuple in which the first value is the full HTML e-mail; the second, the plain text e-mail.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our current docstring format is description, args, returns?

Copy link
Member Author

@kalbfled kalbfled Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's accurate for ENP, but I was not attempting to emulate that here. It's more of a "note to self" at this point. #215 will revisit this function.

Comment on lines 36 to 37
# TODO - Perform substitutions in the subject. Raise ValueError for missing fields.
# TODO - Jinja2 template substitution

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ticket numbers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@@ -0,0 +1,25 @@
# Links With Placeholders

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that all the use cases from the template QA All the Formatting are tested here. Please include them. The below should e enough information for you to go into Portal and edit the template to see the markdown. Below is what we get back from the templates routes for the placeholder in links section.

DEV VANotify Template ID "86820037-1374-4072-9f9f-e74f235170a1"

Fixed Cases:\n1. placeholder at end of [markdown link](https://test.com/((foo)))\n2. placeholder at start of [markdown link](((foo))test.com)\n3. placeholder in middle of [markdown link](https://((foo))-test.com/)\n4. placeholder as [markdown link](((foo)))\n5. multiple placeholders in [markdown link](https://((foo))-test.com?x=((foo)))\n\nEdge Cases: (less likely to happen, but working as expected)\n1. placeholder within markdown link and markdown text [markdown ((foo)) link](https://test.com/((foo)))\n2. multiple placeholders in as query params [markdown link](https://((foo))-test.com?x=((foo))&y=((foo)))\n\n---\n\nA 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are in addition to what is already tested via tests/test_files/markdown/links.md (#198). Placeholder tests focus specifically on what could go wrong during substitution. In the case of links, it's spaces in the URL. For block quotes, it's the insertion of lists.

@kalbfled kalbfled requested a review from MackHalliday March 7, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants