mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
* 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
30 lines
1007 B
Python
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)
|