mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 02:43:12 -04:00
Built py.test cases for convert_markdown_template
This commit is contained in:
@@ -24,12 +24,15 @@ from app.utils.csv import get_user_preferred_timezone
|
|||||||
from app.utils.time import parse_naive_dt
|
from app.utils.time import parse_naive_dt
|
||||||
|
|
||||||
|
|
||||||
def convert_markdown_template(mdf):
|
def convert_markdown_template(mdf, test=False):
|
||||||
APP_ROOT = get_root_path('notifications-admin')
|
if not test:
|
||||||
file = 'app/content/' + mdf + '.md'
|
APP_ROOT = get_root_path('notifications-admin')
|
||||||
md_file = os.path.join(APP_ROOT, file)
|
file = 'app/content/' + mdf + '.md'
|
||||||
with open(md_file) as f:
|
md_file = os.path.join(APP_ROOT, file)
|
||||||
content_text = f.read()
|
with open(md_file) as f:
|
||||||
|
content_text = f.read()
|
||||||
|
else:
|
||||||
|
content_text = mdf
|
||||||
|
|
||||||
md_render = markdown.markdown(content_text)
|
md_render = markdown.markdown(content_text)
|
||||||
jn_render = render_template_string(md_render)
|
jn_render = render_template_string(md_render)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from flask import url_for
|
from flask import url_for, Flask
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from app.formatters import (
|
from app.formatters import (
|
||||||
@@ -12,6 +13,13 @@ from app.formatters import (
|
|||||||
format_notification_status_as_url,
|
format_notification_status_as_url,
|
||||||
format_number_in_pounds_as_currency,
|
format_number_in_pounds_as_currency,
|
||||||
round_to_significant_figures,
|
round_to_significant_figures,
|
||||||
|
convert_markdown_template
|
||||||
|
)
|
||||||
|
|
||||||
|
from tests.conftest import (
|
||||||
|
fake_markdown_file,
|
||||||
|
fake_jinja_template,
|
||||||
|
notify_admin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -166,3 +174,15 @@ def test_email_safe_return_dot_separated_email_domain(service_name, safe_email):
|
|||||||
def test_format_delta():
|
def test_format_delta():
|
||||||
naive_now_utc = datetime.utcnow().isoformat()
|
naive_now_utc = datetime.utcnow().isoformat()
|
||||||
assert format_delta(naive_now_utc) == "just now"
|
assert format_delta(naive_now_utc) == "just now"
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("fake_jinja_template")
|
||||||
|
def test_jinja_format(fake_jinja_template):
|
||||||
|
app = Flask("app")
|
||||||
|
with app.app_context():
|
||||||
|
assert convert_markdown_template(fake_jinja_template, test=True) == "<p>True</p>"
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("fake_markdown_file")
|
||||||
|
def test_markdown_format(fake_markdown_file):
|
||||||
|
app = Flask("app")
|
||||||
|
with app.app_context():
|
||||||
|
assert convert_markdown_template(fake_markdown_file, test=True) == "<h1>Test</h1>"
|
||||||
|
|||||||
@@ -3594,3 +3594,13 @@ def end_to_end_authenticated_context(browser):
|
|||||||
context = browser.new_context(storage_state=auth_state_path)
|
context = browser.new_context(storage_state=auth_state_path)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def fake_markdown_file():
|
||||||
|
input = "#Test"
|
||||||
|
return input
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def fake_jinja_template():
|
||||||
|
input = "{% if True %}True{% endif %}"
|
||||||
|
return input
|
||||||
|
|||||||
Reference in New Issue
Block a user