import os

import pytest


@pytest.fixture
def test_output_dir():
    """Ensure the test_output directory exists, or create it."""
    dir_path = "test_output"

    if not os.path.exists(dir_path):
        os.makedirs(dir_path)

    assert os.path.isdir(dir_path), f"{dir_path} is not a directory"

    return dir_path


@pytest.fixture
def test_instances():
    return {
        "simple": [
            {"step": 0, "length": 0, "intensity": 0, "lactate": 1.0, "heart_rate": 80},
            {
                "step": 1,
                "length": 4,
                "intensity": 8.5,
                "lactate": 1.2,
                "heart_rate": 122,
            },
            {
                "step": 2,
                "length": 4,
                "intensity": 10.0,
                "lactate": 1.3,
                "heart_rate": 131,
            },
            {
                "step": 3,
                "length": 4,
                "intensity": 11.5,
                "lactate": 1.0,
                "heart_rate": 145,
            },
            {
                "step": 4,
                "length": 4,
                "intensity": 13.0,
                "lactate": 0.8,
                "heart_rate": 155,
            },
            {
                "step": 5,
                "length": 4,
                "intensity": 14.5,
                "lactate": 1.1,
                "heart_rate": 162,
            },
            {
                "step": 6,
                "length": 4,
                "intensity": 16.0,
                "lactate": 1.8,
                "heart_rate": 171,
            },
            {
                "step": 7,
                "length": 4,
                "intensity": 17.5,
                "lactate": 2.9,
                "heart_rate": 180,
            },
            {
                "step": 8,
                "length": 4,
                "intensity": 19.0,
                "lactate": 5.3,
                "heart_rate": 186,
            },
        ],
        "differently_named_cols": [
            {
                "step": 0,
                "step_length": 0,
                "intensity": 0,
                "lactate": 1.0,
                "heartrate": 80,
            },
            {
                "step": 1,
                "step_length": 4,
                "intensity": 8.5,
                "lactate": 2.2,
                "heartrate": 122,
            },
            {
                "step": 2,
                "step_length": 4,
                "intensity": 10.0,
                "lactate": 1.3,
                "heartrate": 131,
            },
            {
                "step": 3,
                "step_length": 4,
                "intensity": 11.5,
                "lactate": 1.0,
                "heartrate": 145,
            },
            {
                "step": 4,
                "step_length": 4,
                "intensity": 13.0,
                "lactate": 0.8,
                "heartrate": 155,
            },
            {
                "step": 5,
                "step_length": 4,
                "intensity": 14.5,
                "lactate": 1.1,
                "heartrate": 162,
            },
            {
                "step": 6,
                "step_length": 4,
                "intensity": 16.0,
                "lactate": 1.8,
                "heartrate": 171,
            },
            {
                "step": 7,
                "step_length": 4,
                "intensity": 17.5,
                "lactate": 2.9,
                "heartrate": 180,
            },
            {
                "step": 8,
                "step_length": 4,
                "intensity": 19.0,
                "lactate": 5.3,
                "heartrate": 186,
            },
        ],
        "non_numeric_vals": [
            {"step": 0, "length": 0, "intensity": 0, "lactate": 1.0, "heartrate": 80},
            {
                "step": 1,
                "length": 4,
                "intensity": 8.5,
                "lactate": 2.2,
                "heartrate": 122,
            },
            {
                "step": 2,
                "length": 4,
                "intensity": "a",
                "lactate": 1.3,
                "heartrate": 131,
            },
            {
                "step": 3,
                "length": 4,
                "intensity": 11.5,
                "lactate": 1.0,
                "heartrate": 145,
            },
            {
                "step": 4,
                "length": 4,
                "intensity": 13.0,
                "lactate": 0.8,
                "heartrate": 155,
            },
            {
                "step": 5,
                "length": 4,
                "intensity": 14.5,
                "lactate": 1.1,
                "heartrate": 162,
            },
            {
                "step": 6,
                "length": 4,
                "intensity": 16.0,
                "lactate": 1.8,
                "heartrate": 171,
            },
            {
                "step": 7,
                "length": 4,
                "intensity": 17.5,
                "lactate": 2.9,
                "heartrate": 180,
            },
            {
                "step": 8,
                "length": 4,
                "intensity": 19.0,
                "lactate": 5.3,
                "heartrate": 186,
            },
        ],
        "cycling1": [
            {
                "step": 1,
                "length": 8,
                "intensity": 100,
                "rel_power": 1.2,
                "heart_rate": 120,
                "lactate_4": 1.6,
                "lactate_8": 1.6,
                "cadence": 98,
                "rpe": 6,
                "feeling": "Zeer zeer licht",
            },
            {
                "step": 2,
                "length": 8,
                "intensity": 140,
                "rel_power": 1.7,
                "heart_rate": 132,
                "lactate_4": 1.3,
                "lactate_8": 1.3,
                "cadence": 97,
                "rpe": 9,
                "feeling": "Zeer licht",
            },
            {
                "step": 3,
                "length": 8,
                "intensity": 180,
                "rel_power": 2.2,
                "heart_rate": 144,
                "lactate_4": 1.4,
                "lactate_8": 1.4,
                "cadence": 96,
                "rpe": 11,
                "feeling": "Tamelijk licht",
            },
            {
                "step": 4,
                "length": 8,
                "intensity": 220,
                "rel_power": 2.7,
                "heart_rate": 160,
                "lactate_4": 1.8,
                "lactate_8": 1.8,
                "cadence": 91,
                "rpe": 14,
                "feeling": "Redelijk zwaar",
            },
            {
                "step": 5,
                "length": 8,
                "intensity": 260,
                "rel_power": 3.2,
                "heart_rate": 176,
                "lactate_4": 2.9,
                "lactate_8": 3.4,
                "cadence": 81,
                "rpe": 16,
                "feeling": "Zwaar",
            },
            {
                "step": 6,
                "length": 8,
                "intensity": 300,
                "rel_power": 3.7,
                "heart_rate": 192,
                "lactate_4": 5.5,
                "lactate_8": 6.2,
                "cadence": 81,
                "rpe": 19,
                "feeling": "Zeer zeer zwaar",
            },
        ],
        "cycling2": [
            {
                "step": 1,
                "length": 8,
                "intensity": 100,
                "rel_power": 1.3,
                "heart_rate": 113,
                "lactate_4": 1.0,
                "lactate_8": 1.0,
                "cadence": 102,
                "rpe": 6,
                "feeling": "Zeer zeer licht",
            },
            {
                "step": 2,
                "length": 8,
                "intensity": 140,
                "rel_power": 1.8,
                "heart_rate": 126,
                "lactate_4": 1.0,
                "lactate_8": 1.0,
                "cadence": 100,
                "rpe": 7,
                "feeling": "Zeer zeer licht",
            },
            {
                "step": 3,
                "length": 8,
                "intensity": 180,
                "rel_power": 2.3,
                "heart_rate": 137,
                "lactate_4": 0.9,
                "lactate_8": 0.9,
                "cadence": 100,
                "rpe": 10,
                "feeling": "Zeer licht",
            },
            {
                "step": 4,
                "length": 8,
                "intensity": 220,
                "rel_power": 2.8,
                "heart_rate": 151,
                "lactate_4": 1.0,
                "lactate_8": 1.0,
                "cadence": 98,
                "rpe": 12,
                "feeling": "Tamelijk licht",
            },
            {
                "step": 5,
                "length": 8,
                "intensity": 260,
                "rel_power": 3.3,
                "heart_rate": 168,
                "lactate_4": 1.9,
                "lactate_8": 1.9,
                "cadence": 98,
                "rpe": 16,
                "feeling": "Zwaar",
            },
            {
                "step": 6,
                "length": 8,
                "intensity": 300,
                "rel_power": 3.8,
                "heart_rate": 181,
                "lactate_4": 3.3,
                "lactate_8": 3.8,
                "cadence": 94,
                "rpe": 18,
                "feeling": "Zwaar",
            },
            {
                "step": 7,
                "length": 8,
                "intensity": 340,
                "rel_power": 4.3,
                "heart_rate": 190,
                "lactate_4": 6.4,
                "lactate_8": 7.5,
                "cadence": 92,
                "rpe": 19,
                "feeling": "Zeer zeer zwaar",
            },
        ],
    }
