<commit_before>import re
from unittest import TestCase

import logging

import os
from flask import Flask

from supplychainpy._helpers._config_file_paths import ABS_FILE_PATH_APPLICATION_CONFIG
from supplychainpy._helpers._db_connection import database_connection_uri
from supplychainpy._helpers._pickle_config import serialise_config
from supplychainpy.bot._controller import excess_controller, shortage_controller, revenue_controller, \
    inventory_turns_controller, average_orders_controller, safety_stock_controller, reorder_level_controller
from supplychainpy.launch_reports import load_db
from supplychainpy.reporting.config.settings import IntegrationConfig
from supplychainpy.reporting.extensions import db
from supplychainpy.sample_data.config import ABS_FILE_PATH

logging.basicConfig(level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s')


class TestBotController(TestCase):

    def test_controllers(self):
        app = Flask(__name__, instance_relative_config=True)
        PWD = os.path.abspath(os.curdir)
        i_c = IntegrationConfig
        i_c.SQLALCHEMY_DATABASE_URI = 'sqlite:///{}/reporting.db'.format(PWD)
        app.config.from_object(i_c)
        print(PWD)
        app.config['DATABASE'] = PWD
        app.config['TESTING'] = True
        self.app = app.test_client()
        self._file= ABS_FILE_PATH['COMPLETE_CSV_XSM']
        app_settings = {
            'file': self._file,
            'currency': 'USD',
            'database_path': PWD,
        }

        serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG)
        with app.app_context():
            db.init_app(app)
            db.create_all()
            load_db(file=self._file, location=PWD)

        smallest_excess = excess_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')
        largest_excess = excess_controller(database_connection_uri(retrieve='retrieve'), direction='biggest')
        smallest_sishortage = shortage_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')
        largest_shortage = shortage_controller(database_connection_uri(retrieve='retrieve'), direction='biggest')
        smallest_revenue = revenue_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')<commit_msg>correct typo smallest_shortage<commit_after>import re
from unittest import TestCase

import logging

import os
from flask import Flask

from supplychainpy._helpers._config_file_paths import ABS_FILE_PATH_APPLICATION_CONFIG
from supplychainpy._helpers._db_connection import database_connection_uri
from supplychainpy._helpers._pickle_config import serialise_config
from supplychainpy.bot._controller import excess_controller, shortage_controller, revenue_controller, \
    inventory_turns_controller, average_orders_controller, safety_stock_controller, reorder_level_controller
from supplychainpy.launch_reports import load_db
from supplychainpy.reporting.config.settings import IntegrationConfig
from supplychainpy.reporting.extensions import db
from supplychainpy.sample_data.config import ABS_FILE_PATH

logging.basicConfig(level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s')


class TestBotController(TestCase):

    def test_controllers(self):
        app = Flask(__name__, instance_relative_config=True)
        PWD = os.path.abspath(os.curdir)
        i_c = IntegrationConfig
        i_c.SQLALCHEMY_DATABASE_URI = 'sqlite:///{}/reporting.db'.format(PWD)
        app.config.from_object(i_c)
        print(PWD)
        app.config['DATABASE'] = PWD
        app.config['TESTING'] = True
        self.app = app.test_client()
        self._file= ABS_FILE_PATH['COMPLETE_CSV_XSM']
        app_settings = {
            'file': self._file,
            'currency': 'USD',
            'database_path': PWD,
        }

        serialise_config(app_settings, ABS_FILE_PATH_APPLICATION_CONFIG)
        with app.app_context():
            db.init_app(app)
            db.create_all()
            load_db(file=self._file, location=PWD)

        smallest_excess = excess_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')
        largest_excess = excess_controller(database_connection_uri(retrieve='retrieve'), direction='biggest')
        smallest_shortage = shortage_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')
        largest_shortage = shortage_controller(database_connection_uri(retrieve='retrieve'), direction='biggest')
        smallest_revenue = revenue_controller(database_connection_uri(retrieve='retrieve'), direction='smallest')
{'fraction_non_alphanumeric': 0.08884073672806067, 'fraction_numerical': 0.0, 'mean_word_length': 4.608748481166464, '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': '5370272', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1316, 'n_words': 219}