Files
DicePlayer/tests/dice/test_dice_input.py

71 lines
2.0 KiB
Python

from diceplayer.config import PlayerConfig
from diceplayer.dice.dice_input import (
NPTEqConfig,
NPTTerConfig,
NVTEqConfig,
NVTTerConfig,
)
import pytest
from pathlib import Path
class TestDiceInput:
@pytest.fixture
def player_config(self) -> PlayerConfig:
return PlayerConfig.model_validate(
{
"type": "both",
"mem": 12,
"max_cyc": 100,
"switch_cyc": 50,
"nprocs": 4,
"ncores": 4,
"dice": {
"ljname": "test",
"outname": "test",
"dens": 1.0,
"nmol": [1],
"nstep": [1, 1],
},
"gaussian": {
"level": "test",
"qmprog": "g16",
"keywords": "test",
},
}
)
def test_generate_nvt_ter_input(self, player_config: PlayerConfig):
dice_input = NVTTerConfig.from_config(player_config)
assert isinstance(dice_input, NVTTerConfig)
def test_generate_nvt_eq_input(self, player_config: PlayerConfig):
dice_input = NVTEqConfig.from_config(player_config)
assert isinstance(dice_input, NVTEqConfig)
def test_generate_npt_ter_input(self, player_config: PlayerConfig):
dice_input = NPTTerConfig.from_config(player_config)
assert isinstance(dice_input, NPTTerConfig)
def test_generate_npt_eq_input(self, player_config: PlayerConfig):
dice_input = NPTEqConfig.from_config(player_config)
assert isinstance(dice_input, NPTEqConfig)
def test_write_dice_config(self, player_config: PlayerConfig, tmp_path: Path):
dice_input = NVTTerConfig.from_config(player_config)
output_file = tmp_path / "nvt_ter.inp"
with open(output_file, "w") as file:
dice_input.write_dice_config(file)
assert output_file.exists()
print(output_file.read_text())