<commit_before>import pytest

from data.test_config.example_policy import ExamplePolicy
from rasa_core.config import load, handle_precedence_and_defaults
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.policies.ensemble import PolicyEnsemble


def test_handle_precedence_and_defaults():

    config_data = {'policies':[
        {'name':'FallbackPolicy', 'nlu_threshold':0.5},
        {'name':'KerasPolicy'}
    ]}
    fallback_args = {
        'nlu_threshold': 1,
        'core_threshold':1,
        'fallback_action_name':'some_name'
    }
    expected_config_data = {'policies': [
        {'name': 'FallbackPolicy', 'nlu_threshold' :1,
        'core_threshold': 1, 'fallback_action_name': 'some_name'},
        {'name': 'KerasPolicy', 'max_history': 3}
    ]}
    new_config_data = handle_precedence_and_defaults(
                            config_data, fallback_args, max_history)
    assert new_config_data == expected_config_data

def test_load():

    loaded = load("data/test_config/example_config.yaml", None, None)
    assert loaded == [MemoizationPolicy(max_history=5),
                      ExamplePolicy(example_arg=10)]<commit_msg>remove unnecessary import<commit_after>import pytest

from data.test_config.example_policy import ExamplePolicy
from rasa_core.config import load, handle_precedence_and_defaults
from rasa_core.policies.memoization import MemoizationPolicy


def test_handle_precedence_and_defaults():

    config_data = {'policies':[
        {'name':'FallbackPolicy', 'nlu_threshold':0.5},
        {'name':'KerasPolicy'}
    ]}
    fallback_args = {
        'nlu_threshold': 1,
        'core_threshold':1,
        'fallback_action_name':'some_name'
    }
    expected_config_data = {'policies': [
        {'name': 'FallbackPolicy', 'nlu_threshold' :1,
        'core_threshold': 1, 'fallback_action_name': 'some_name'},
        {'name': 'KerasPolicy', 'max_history': 3}
    ]}
    new_config_data = handle_precedence_and_defaults(
                            config_data, fallback_args, max_history)
    assert new_config_data == expected_config_data

def test_load():

    loaded = load("data/test_config/example_config.yaml", None, None)
    assert loaded == [MemoizationPolicy(max_history=5),
                      ExamplePolicy(example_arg=10)]
{'fraction_non_alphanumeric': 0.11202778983933999, 'fraction_numerical': 0.008684324793747287, 'mean_word_length': 3.731006160164271, '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': '4379297', 'n_tokens_mistral': 734, 'n_tokens_neox': 710, 'n_words': 123}