refactor: update imports and switch to pytest for testing
This commit is contained in:
89
tests/config/test_dice_config.py
Normal file
89
tests/config/test_dice_config.py
Normal file
@@ -0,0 +1,89 @@
|
||||
from diceplayer.config.dice_config import DiceConfig
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestDiceConfig:
|
||||
def test_class_instantiation(self):
|
||||
dice_dto = DiceConfig(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
{
|
||||
"ljname": "test",
|
||||
"outname": "test",
|
||||
"dens": 1.0,
|
||||
"nmol": [1],
|
||||
"nstep": [1, 1],
|
||||
}
|
||||
)
|
||||
|
||||
assert isinstance(dice_dto, DiceConfig)
|
||||
Reference in New Issue
Block a user