Files
notifications-api/tests/app/letters/test_letter_utils.py
Richard Chapman a4feaba309 Added tests to tests for precompiled flow and refactored a little
* Added is_precompiled_letter method to letter/utils.py
* Added tests for letter/utils.py
* Added tests for the rest endpoint
* Moved the Precompiled name to a central location
* Added hidden field to the test method to create a template
2018-03-05 14:11:37 +00:00

30 lines
1007 B
Python

import pytest
from flask import current_app
from app.letters.utils import get_bucket_prefix_for_notification, is_precompiled_letter
def test_get_bucket_prefix_for_notification_valid_notification(sample_notification):
bucket_prefix = get_bucket_prefix_for_notification(sample_notification)
assert bucket_prefix == '{folder}/NOTIFY.{reference}'.format(
folder=sample_notification.created_at.date(),
reference=sample_notification.reference
).upper()
def test_get_bucket_prefix_for_notification_invalid_notification():
with pytest.raises(AttributeError):
get_bucket_prefix_for_notification(None)
def test_is_precompiled_letter_false(sample_letter_template):
assert not is_precompiled_letter(sample_letter_template)
def test_is_precompiled_letter_true(sample_letter_template):
sample_letter_template.hidden = True
sample_letter_template.name = current_app.config['PRECOMPILED_TEMPLATE_NAME']
assert is_precompiled_letter(sample_letter_template)