<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_draftin_a_flask
----------------------------------

Tests for `draftin_a_flask` module.
"""

import pytest
import os

from draftin_a_flask import draftin_a_flask

def test_on_server_setup_if_secret_keyfile_is_missing_it_should_create():
    package_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    secret_file = os.path.join(package_root, 'draftin_a_flask', 's3kret.key')
    if os.path.isfile(secret_file):
        os.unlink(secret_file)
    assert not os.path.exists(secret_file)

    draftin_a_flask.setup()

    assert os.path.isfile(secret_file)<commit_msg>Refactored test<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
test_draftin_a_flask
----------------------------------

Tests for `draftin_a_flask` module.
"""

import pytest
import os

from draftin_a_flask import draftin_a_flask

@pytest.fixture
def secret_file():
    package_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    secret_file = os.path.join(package_root, 'draftin_a_flask', 's3kret.key')
    return secret_file

def test_if_secret_keyfile_is_missing_it_should_create_on_setup(secret_file):
    if os.path.isfile(secret_file):
        os.unlink(secret_file)
    assert not os.path.exists(secret_file)

    draftin_a_flask.setup()

    assert os.path.isfile(secret_file)
{'fraction_non_alphanumeric': 0.15927272727272726, 'fraction_numerical': 0.002909090909090909, 'mean_word_length': 3.696245733788396, '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': '3284300', 'n_tokens_mistral': 508, 'n_tokens_neox': 503, 'n_words': 73}