Files
DicePlayer/tests/config/test_dice_config.py

97 lines
2.5 KiB
Python

from diceplayer.config.dice_config import DiceConfig
import pytest
class TestDiceConfig:
def test_class_instantiation(self):
dice_dto = DiceConfig(
nprocs=1,
ljname="test",
outname="test",
dens=1.0,
nmol=[1],
nstep=[1, 1],
)
assert isinstance(dice_dto, DiceConfig)
def test_validate_jname(self):
with pytest.raises(ValueError) as ex:
DiceConfig(
nprocs=1,
ljname=None,
outname="test",
dens=1.0,
nmol=[1],
nstep=[1, 1],
)
assert ex.value == "Error: 'ljname' keyword not specified in config file"
def test_validate_outname(self):
with pytest.raises(ValueError) as ex:
DiceConfig(
nprocs=1,
ljname="test",
outname=None,
dens=1.0,
nmol=[1],
nstep=[1, 1],
)
assert ex.value == "Error: 'outname' keyword not specified in config file"
def test_validate_dens(self):
with pytest.raises(ValueError) as ex:
DiceConfig(
nprocs=1,
ljname="test",
outname="test",
dens=None,
nmol=[1],
nstep=[1, 1],
)
assert ex.value == "Error: 'dens' keyword not specified in config file"
def test_validate_nmol(self):
with pytest.raises(ValueError) as ex:
DiceConfig(
nprocs=1,
ljname="test",
outname="test",
dens=1.0,
nmol=0,
nstep=[1, 1],
)
assert ex.value == "Error: 'nmol' keyword not specified in config file"
def test_validate_nstep(self):
with pytest.raises(ValueError) as ex:
DiceConfig(
nprocs=1,
ljname="test",
outname="test",
dens=1.0,
nmol=[1],
nstep=0,
)
assert ex.value == "Error: 'nstep' keyword not specified in config file"
def test_from_dict(self):
dice_dto = DiceConfig.model_validate(
{
"nprocs": 1,
"ljname": "test",
"outname": "test",
"dens": 1.0,
"nmol": [1],
"nstep": [1, 1],
}
)
assert isinstance(dice_dto, DiceConfig)