feat: Create a helper function for the d666 special die
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from gm_assistant.dice import Die
|
||||
from gm_assistant.dice import Die, d666
|
||||
|
||||
|
||||
def test_parse_empty() -> None:
|
||||
@@ -143,3 +143,45 @@ def test_roll_complex(mocker: MockerFixture) -> None:
|
||||
mocker.call(1, 4),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_d666_strict_order(mocker: MockerFixture) -> None:
|
||||
"""Test ``d666()`` with strict dice order"""
|
||||
|
||||
mocked_randint = mocker.patch("gm_assistant.dice.random.randint", side_effect=[2, 4, 6])
|
||||
|
||||
assert d666(strict_order=True) == [246]
|
||||
assert mocked_randint.call_count == 3
|
||||
mocked_randint.assert_has_calls([mocker.call(1, 6), mocker.call(1, 6), mocker.call(1, 6)])
|
||||
|
||||
|
||||
def test_d666_any_order(mocker: MockerFixture) -> None:
|
||||
"""Test ``d666()`` without strict order"""
|
||||
|
||||
mocked_randint = mocker.patch("gm_assistant.dice.random.randint", side_effect=[2, 4, 6])
|
||||
|
||||
assert d666(strict_order=False) == [246, 264, 426, 462, 624, 642]
|
||||
assert mocked_randint.call_count == 3
|
||||
mocked_randint.assert_has_calls([mocker.call(1, 6), mocker.call(1, 6), mocker.call(1, 6)])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dice_values", [pytest.param((1, 1, 2)), pytest.param((1, 2, 1)), pytest.param((2, 1, 1))])
|
||||
def test_d666_equal_dice(dice_values: tuple[int, int, int], mocker: MockerFixture) -> None:
|
||||
"""Test ``d666()`` when some dice are equal"""
|
||||
|
||||
mocked_randint = mocker.patch("gm_assistant.dice.random.randint", side_effect=dice_values)
|
||||
|
||||
assert set(d666()) == set((112, 121, 211))
|
||||
assert mocked_randint.call_count == 3
|
||||
mocked_randint.assert_has_calls([mocker.call(1, 6), mocker.call(1, 6), mocker.call(1, 6)])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("strict_order", (True, False), ids=("strict", "any"))
|
||||
def test_d666_all_equal(strict_order: bool, mocker: MockerFixture) -> None:
|
||||
"""Test ``d666()`` when all dice are equal"""
|
||||
|
||||
mocked_randint = mocker.patch("gm_assistant.dice.random.randint", return_value=5)
|
||||
|
||||
assert d666(strict_order=strict_order) == [555]
|
||||
assert mocked_randint.call_count == 3
|
||||
mocked_randint.assert_has_calls([mocker.call(1, 6), mocker.call(1, 6), mocker.call(1, 6)])
|
||||
|
Reference in New Issue
Block a user