gm-assistant/tests/test_fate_chart.py

52 lines
1.6 KiB
Python

# SPDX-FileCopyrightText: 2025 2025
# SPDX-FileContributor: Gergely Polonkai
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for the Fate Chart module"""
import pytest
from pytest_mock import MockerFixture
from gm_assistant.fate_chart import FateOdds, FateOutcome, decide
@pytest.mark.parametrize("odds", FateOdds)
@pytest.mark.parametrize("chaos_level", range(9))
def test_all_valid_values(odds: FateOdds, chaos_level: int) -> None:
"""Test if every valid value yields some result"""
assert isinstance(decide(odds, chaos_level=chaos_level), FateOutcome)
# WARNING
#
# Tests below this line rely on exact values in the fate_chart module
def test_exceptional_yes(mocker: MockerFixture) -> None:
"""Test if exceptional yes result is returned"""
mocker.patch("gm_assistant.fate_chart.Die.roll", return_value=10)
assert decide(FateOdds.FIFTY_FIFTY, chaos_level=5) == FateOutcome.EXC_YES
def test_yes(mocker: MockerFixture) -> None:
"""Test if yes result is returned"""
mocker.patch("gm_assistant.fate_chart.Die.roll", return_value=50)
assert decide(FateOdds.FIFTY_FIFTY, chaos_level=5) == FateOutcome.YES
def test_exceptional_no(mocker: MockerFixture) -> None:
"""Test if exceptional no result is returned"""
mocker.patch("gm_assistant.fate_chart.Die.roll", return_value=91)
assert decide(FateOdds.FIFTY_FIFTY, chaos_level=5) == FateOutcome.EXC_NO
def test_no(mocker: MockerFixture) -> None:
"""Test if exceptional no result is returned"""
mocker.patch("gm_assistant.fate_chart.Die.roll", return_value=51)
assert decide(FateOdds.FIFTY_FIFTY, chaos_level=5) == FateOutcome.NO