84 lines
2.1 KiB
Python
84 lines
2.1 KiB
Python
from diceplayer.config.dice_config import DiceConfig
|
|
from diceplayer.config.gaussian_config import GaussianConfig
|
|
from diceplayer.config.player_config import PlayerConfig
|
|
|
|
import pytest
|
|
|
|
|
|
def get_config_dict():
|
|
return {
|
|
"opt": True,
|
|
"mem": 12,
|
|
"maxcyc": 100,
|
|
"nprocs": 4,
|
|
"ncores": 4,
|
|
"dice": {
|
|
"ljname": "test",
|
|
"outname": "test",
|
|
"dens": 1.0,
|
|
"nmol": [1],
|
|
"nstep": [1, 1],
|
|
},
|
|
"gaussian": {
|
|
"level": "test",
|
|
"qmprog": "g16",
|
|
"keywords": "test",
|
|
},
|
|
}
|
|
|
|
|
|
class TestPlayerConfig:
|
|
@pytest.fixture
|
|
def dice_config(self):
|
|
return DiceConfig(
|
|
ljname="test",
|
|
outname="test",
|
|
dens=1.0,
|
|
nmol=[1],
|
|
nstep=[1, 1],
|
|
)
|
|
|
|
@pytest.fixture
|
|
def gaussian_config(self):
|
|
return GaussianConfig(
|
|
level="test",
|
|
qmprog="g16",
|
|
keywords="test",
|
|
)
|
|
|
|
def test_class_instantiation(self, dice_config, gaussian_config):
|
|
player_dto = PlayerConfig(
|
|
opt=True,
|
|
mem=12,
|
|
maxcyc=100,
|
|
nprocs=4,
|
|
ncores=4,
|
|
dice=dice_config,
|
|
gaussian=gaussian_config,
|
|
)
|
|
|
|
assert isinstance(player_dto, PlayerConfig)
|
|
assert isinstance(player_dto.dice, DiceConfig)
|
|
assert isinstance(player_dto.gaussian, GaussianConfig)
|
|
|
|
def test_min_altsteps(self, dice_config, gaussian_config):
|
|
player_dto = PlayerConfig(
|
|
opt=True,
|
|
mem=12,
|
|
maxcyc=100,
|
|
nprocs=4,
|
|
ncores=4,
|
|
altsteps=100,
|
|
dice=dice_config,
|
|
gaussian=gaussian_config,
|
|
)
|
|
|
|
assert player_dto.altsteps == 20000
|
|
|
|
def test_from_dict(self):
|
|
player_dto = PlayerConfig.model_validate(get_config_dict())
|
|
|
|
assert isinstance(player_dto, PlayerConfig)
|
|
assert isinstance(player_dto.dice, DiceConfig)
|
|
assert isinstance(player_dto.gaussian, GaussianConfig)
|