2023-12-08 14:52:40 -08:00
|
|
|
import pytest
|
|
|
|
|
2024-01-16 22:05:06 -08:00
|
|
|
from pathlib import Path
|
|
|
|
from rolltable.types import RollTable
|
2022-07-30 14:20:26 -07:00
|
|
|
|
|
|
|
|
2024-01-16 22:05:06 -08:00
|
|
|
sources = Path(__file__).parent / '..' / 'rolltable' / 'sources'
|
2022-07-30 14:20:26 -07:00
|
|
|
|
2024-01-16 22:05:06 -08:00
|
|
|
flat_list = (sources / 'trinkets.yaml').read_text()
|
|
|
|
dict_of_dicts = (sources / 'wild_magic.yaml').read_text()
|
|
|
|
dict_of_lists = (sources / 'psychadelic_effects.yaml').read_text()
|
2022-07-30 14:20:26 -07:00
|
|
|
|
|
|
|
|
2024-01-16 22:05:06 -08:00
|
|
|
@pytest.mark.parametrize('data, expected', [
|
|
|
|
([dict_of_dicts], ['d1000 ', 'A third eye', 'Advantage on perception checks']),
|
|
|
|
([flat_list], ['d1000 ', 'ivory mimic']),
|
|
|
|
([dict_of_lists], ['d1000', 'Cosmic', 'mind expands', 'it will become so']),
|
2023-12-22 23:22:17 -08:00
|
|
|
])
|
2024-01-16 22:05:06 -08:00
|
|
|
def test_flat(data, expected):
|
|
|
|
rt = RollTable(data, die=1000)
|
|
|
|
for txt in expected:
|
|
|
|
assert txt in str(rt)
|