Implements Refactoring in Player Class and Initial Working Version
This commit is contained in:
@@ -1,28 +1,84 @@
|
||||
from diceplayer.shared.config.player_dto import PlayerDTO
|
||||
from diceplayer.shared.config.gaussian_config import GaussianDTO
|
||||
from diceplayer.shared.config.player_config import PlayerConfig
|
||||
from diceplayer.shared.config.dice_config import DiceConfig
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class TestPlayerDTO(unittest.TestCase):
|
||||
def test_class_instantiation(self):
|
||||
player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4, ncores=4)
|
||||
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',
|
||||
}
|
||||
}
|
||||
|
||||
self.assertIsInstance(player_dto, PlayerDTO)
|
||||
|
||||
class TestPlayerDTO(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.dice_dto = DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.gaussian_dto = GaussianDTO(
|
||||
level='test',
|
||||
qmprog='g16',
|
||||
keywords='test',
|
||||
)
|
||||
|
||||
def test_class_instantiation(self):
|
||||
player_dto = PlayerConfig(
|
||||
opt=True,
|
||||
mem=12,
|
||||
maxcyc=100,
|
||||
nprocs=4,
|
||||
ncores=4,
|
||||
dice=self.dice_dto,
|
||||
gaussian=self.gaussian_dto
|
||||
)
|
||||
|
||||
self.assertIsInstance(player_dto, PlayerConfig)
|
||||
self.assertIsInstance(player_dto.dice, DiceConfig)
|
||||
self.assertIsInstance(player_dto.gaussian, GaussianDTO)
|
||||
|
||||
def test_min_altsteps(self):
|
||||
player_dto = PlayerDTO(opt=True, maxcyc=100, nprocs=4, ncores=4, altsteps=100)
|
||||
player_dto = PlayerConfig(
|
||||
opt=True,
|
||||
mem=12,
|
||||
maxcyc=100,
|
||||
nprocs=4,
|
||||
ncores=4,
|
||||
altsteps=100,
|
||||
dice=self.dice_dto,
|
||||
gaussian=self.gaussian_dto
|
||||
)
|
||||
|
||||
self.assertEqual(player_dto.altsteps, 20000)
|
||||
|
||||
def test_from_dict(self):
|
||||
player_dto = PlayerDTO.from_dict({
|
||||
'opt': True,
|
||||
'maxcyc': 100,
|
||||
'nprocs': 4,
|
||||
'ncores': 4,
|
||||
})
|
||||
player_dto = PlayerConfig.from_dict(
|
||||
get_config_dict()
|
||||
)
|
||||
|
||||
self.assertIsInstance(player_dto, PlayerDTO)
|
||||
self.assertIsInstance(player_dto, PlayerConfig)
|
||||
self.assertIsInstance(player_dto.dice, DiceConfig)
|
||||
self.assertIsInstance(player_dto.gaussian, GaussianDTO)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user