Implementa Test para Metodo make_init_file

This commit is contained in:
2023-04-26 21:25:00 +00:00
committed by GitHub
parent a13088c409
commit 420b36b872
3 changed files with 40 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ import time
import sys import sys
import os import os
DICE_END_FLAG: Final[str] = "End of simulation" DICE_END_FLAG: Final[str] = "End of simulation"
DICE_FLAG_LINE: Final[int] = -2 DICE_FLAG_LINE: Final[int] = -2
UMAANG3_TO_GCM3: Final[float] = 1.6605 UMAANG3_TO_GCM3: Final[float] = 1.6605

View File

@@ -5,12 +5,12 @@ import unittest
class TestPlayerDTO(unittest.TestCase): class TestPlayerDTO(unittest.TestCase):
def test_class_instantiation(self): def test_class_instantiation(self):
player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4) player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4, ncores=4)
self.assertIsInstance(player_dto, PlayerDTO) self.assertIsInstance(player_dto, PlayerDTO)
def test_min_altsteps(self): def test_min_altsteps(self):
player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4, altsteps=100) player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4, ncores=4, altsteps=100)
self.assertEqual(player_dto.altsteps, 20000) self.assertEqual(player_dto.altsteps, 20000)
@@ -18,7 +18,8 @@ class TestPlayerDTO(unittest.TestCase):
player_dto = PlayerDTO.from_dict({ player_dto = PlayerDTO.from_dict({
'opt': True, 'opt': True,
'maxcyc': 100, 'maxcyc': 100,
'nprocs': 4 'nprocs': 4,
'ncores': 4,
}) })
self.assertIsInstance(player_dto, PlayerDTO) self.assertIsInstance(player_dto, PlayerDTO)

View File

@@ -1,6 +1,9 @@
from diceplayer.shared.interface.dice_interface import DiceInterface from diceplayer.shared.interface.dice_interface import DiceInterface
from diceplayer.shared.environment.molecule import Molecule
from diceplayer.shared.config.step_dto import StepDTO from diceplayer.shared.config.step_dto import StepDTO
import io
from tests.mocks.mock_proc import MockConnection, MockProc from tests.mocks.mock_proc import MockConnection, MockProc
from unittest import mock from unittest import mock
@@ -560,6 +563,38 @@ class TestDiceInterface(unittest.TestCase):
with self.assertRaises(FileNotFoundError): with self.assertRaises(FileNotFoundError):
dice._run_dice(1, 1) dice._run_dice(1, 1)
def test_make_init_file(self):
dice = DiceInterface(
{
'ljname': 'test',
'outname': 'test',
'ncores': 1,
'dens': 1.0,
'nmol': [1],
'nstep': [1, 1],
}
)
dice.configure(
StepDTO(
ncores=1,
nprocs=1,
simulation_dir='test',
altsteps=1,
molecule=[
],
nmol=[],
)
)
last_xyz_file = io.StringIO()
last_xyz_file.writelines([
'TEST',
'TEST',
'TEST',
'TEST',
])
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()