91 lines
2.6 KiB
Python
91 lines
2.6 KiB
Python
from diceplayer.config.dice_config import DiceConfig
|
|
from diceplayer.config.gaussian_config import GaussianConfig
|
|
from diceplayer.config.player_config import PlayerConfig, RoutineType
|
|
|
|
import pytest
|
|
|
|
from typing import Any
|
|
|
|
|
|
class TestPlayerConfig:
|
|
@pytest.fixture
|
|
def dice_payload(self) -> dict[str, Any]:
|
|
return {
|
|
"nprocs": 4,
|
|
"ljname": "test",
|
|
"outname": "test",
|
|
"dens": 1.0,
|
|
"nmol": [1],
|
|
"nstep": [1, 1],
|
|
}
|
|
|
|
@pytest.fixture
|
|
def gaussian_payload(self) -> dict[str, Any]:
|
|
return {
|
|
"level": "test",
|
|
"qmprog": "g16",
|
|
"keywords": "test",
|
|
}
|
|
|
|
@pytest.fixture
|
|
def player_payload(
|
|
self, dice_payload: dict[str, Any], gaussian_payload: dict[str, Any]
|
|
) -> dict[str, Any]:
|
|
return {
|
|
"type": "both",
|
|
"mem": 12,
|
|
"max_cyc": 100,
|
|
"switch_cyc": 50,
|
|
"ncores": 4,
|
|
"dice": dice_payload,
|
|
"gaussian": gaussian_payload,
|
|
}
|
|
|
|
@pytest.fixture
|
|
def dice_config(self, dice_payload: dict[str, Any]) -> DiceConfig:
|
|
return DiceConfig.model_validate(dice_payload)
|
|
|
|
@pytest.fixture
|
|
def gaussian_config(self, gaussian_payload: dict[str, Any]):
|
|
return GaussianConfig.model_validate(gaussian_payload)
|
|
|
|
def test_class_instantiation(
|
|
self, dice_config: DiceConfig, gaussian_config: GaussianConfig
|
|
):
|
|
player_dto = PlayerConfig(
|
|
type=RoutineType.BOTH,
|
|
mem=12,
|
|
max_cyc=100,
|
|
switch_cyc=50,
|
|
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: DiceConfig, gaussian_config: GaussianConfig
|
|
):
|
|
player_dto = PlayerConfig(
|
|
type=RoutineType.BOTH,
|
|
mem=12,
|
|
max_cyc=100,
|
|
switch_cyc=50,
|
|
ncores=4,
|
|
altsteps=0,
|
|
dice=dice_config,
|
|
gaussian=gaussian_config,
|
|
)
|
|
|
|
assert player_dto.altsteps == 20000
|
|
|
|
def test_from_dict(self, player_payload: dict[str, Any]):
|
|
player_dto = PlayerConfig.model_validate(player_payload)
|
|
|
|
assert isinstance(player_dto, PlayerConfig)
|
|
assert isinstance(player_dto.dice, DiceConfig)
|
|
assert isinstance(player_dto.gaussian, GaussianConfig)
|