adding tests
This commit is contained in:
parent
76ed17a650
commit
5874309d9c
49
test/test_datasources.py
Normal file
49
test/test_datasources.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from io import StringIO
|
||||
|
||||
from random_sets import datasources
|
||||
from pprint import pprint as print
|
||||
|
||||
fixture_metadata = """
|
||||
metadata:
|
||||
headers:
|
||||
- Header 1
|
||||
- Header 2
|
||||
- Header 3
|
||||
die: 10
|
||||
frequencies:
|
||||
default:
|
||||
Option 1: 0.3
|
||||
Option 2: 0.5
|
||||
Option 3: 0.2
|
||||
nondefault:
|
||||
Option 1: 0.0
|
||||
Option 2: 0.1
|
||||
Option 3: 0.9
|
||||
"""
|
||||
|
||||
fixture_source = """
|
||||
Option 1:
|
||||
- choice 1: description 1
|
||||
- choice 2: description 2
|
||||
- choice 3: description 3
|
||||
Option 2:
|
||||
- choice 1: description 4
|
||||
- choice 2: description 5
|
||||
- choice 3: description 6
|
||||
Option 3:
|
||||
- choice 1: description 7
|
||||
- choice 2: description 8
|
||||
- choice 3: description 9
|
||||
"""
|
||||
|
||||
|
||||
def test_datasource_random_values():
|
||||
fixture = StringIO(fixture_metadata + fixture_source)
|
||||
ds = datasources.DataSource(fixture)
|
||||
randvals = ds.random_values(count=2)
|
||||
|
||||
# we asked for two random values
|
||||
assert len(randvals) == 2
|
||||
|
||||
# each value has an "Option", a "choice", and a "description"
|
||||
assert len(randvals[0]) == 3
|
Loading…
Reference in New Issue
Block a user