<commit_before>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)<commit_msg>Added tests for all conditions for s_precompiled_letter.<commit_after>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)


def test_is_precompiled_letter_hidden_true_not_name(sample_letter_template):
    sample_letter_template.hidden = True
    assert not is_precompiled_letter(sample_letter_template)


def test_is_precompiled_letter_name_correct_not_hidden(sample_letter_template):
    sample_letter_template.name = current_app.config['PRECOMPILED_TEMPLATE_NAME']
    assert not is_precompiled_letter(sample_letter_template)
{'fraction_non_alphanumeric': 0.058846918489065606, 'fraction_numerical': 0.0, 'mean_word_length': 7.646048109965636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3384870', 'n_tokens_mistral': 744, 'n_tokens_neox': 716, 'n_words': 97}