mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
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
This commit is contained in:
29
tests/app/letters/test_letter_utils.py
Normal file
29
tests/app/letters/test_letter_utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user