import os

from rasa_core.evaluate import run_story_evaluation, \
    collect_story_predictions
from tests.conftest import DEFAULT_STORIES_FILE
import imghdr


def test_evaluation_image_creation(tmpdir):
    img_path = os.path.join(tmpdir.strpath, "evaltion.png")
    run_story_evaluation(
            story_file="examples/concerts/data/stories.md",
            policy_model_path="examples/concerts/models/policy/init",
            nlu_model_path=None,
            out_file=img_path,
            max_stories=None
    )

    assert os.path.isfile(img_path)
    assert imghdr.what(img_path) == "png"


def test_evaluation_script():
    actual, preds = collect_story_predictions(
            story_file="examples/concerts/data/stories.md",
            policy_model_path="examples/concerts/models/policy/init",
            nlu_model_path=None,
            max_stories=None,
            shuffle_stories=False
    )
    assert len(actual) == 14
    assert len(preds) == 14

import imghdr
import os

import matplotlib

from rasa_core.evaluate import run_story_evaluation, \
    collect_story_predictions

matplotlib.use('Agg')


def test_evaluation_image_creation(tmpdir):
    img_path = os.path.join(tmpdir.strpath, "evaltion.png")
    run_story_evaluation(
            story_file="examples/concerts/data/stories.md",
            policy_model_path="examples/concerts/models/policy/init",
            nlu_model_path=None,
            out_file=img_path,
            max_stories=None
    )

    assert os.path.isfile(img_path)
    assert imghdr.what(img_path) == "png"


def test_evaluation_script():
    actual, preds = collect_story_predictions(
            story_file="examples/concerts/data/stories.md",
            policy_model_path="examples/concerts/models/policy/init",
            nlu_model_path=None,
            max_stories=None,
            shuffle_stories=False
    )
    assert len(actual) == 14
    assert len(preds) == 14

use agg during plotting test