Adds Formatter to Project
This commit is contained in:
@@ -6,8 +6,8 @@ import unittest
|
||||
class TestDiceDto(unittest.TestCase):
|
||||
def test_class_instantiation(self):
|
||||
dice_dto = DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
@@ -19,64 +19,78 @@ class TestDiceDto(unittest.TestCase):
|
||||
with self.assertRaises(ValueError) as ex:
|
||||
DiceConfig(
|
||||
ljname=None,
|
||||
outname='test',
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.assertEqual(ex.exception, "Error: 'ljname' keyword not specified in config file")
|
||||
self.assertEqual(
|
||||
ex.exception, "Error: 'ljname' keyword not specified in config file"
|
||||
)
|
||||
|
||||
def test_validate_outname(self):
|
||||
with self.assertRaises(ValueError) as ex:
|
||||
DiceConfig(
|
||||
ljname='test',
|
||||
ljname="test",
|
||||
outname=None,
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.assertEqual(ex.exception, "Error: 'outname' keyword not specified in config file")
|
||||
self.assertEqual(
|
||||
ex.exception, "Error: 'outname' keyword not specified in config file"
|
||||
)
|
||||
|
||||
def test_validate_dens(self):
|
||||
with self.assertRaises(ValueError) as ex:
|
||||
DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=None,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.assertEqual(ex.exception, "Error: 'dens' keyword not specified in config file")
|
||||
self.assertEqual(
|
||||
ex.exception, "Error: 'dens' keyword not specified in config file"
|
||||
)
|
||||
|
||||
def test_validate_nmol(self):
|
||||
with self.assertRaises(ValueError) as ex:
|
||||
DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=0,
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.assertEqual(ex.exception, "Error: 'nmol' keyword not defined appropriately in config file")
|
||||
self.assertEqual(
|
||||
ex.exception,
|
||||
"Error: 'nmol' keyword not defined appropriately in config file",
|
||||
)
|
||||
|
||||
def test_validate_nstep(self):
|
||||
with self.assertRaises(ValueError) as ex:
|
||||
DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=0,
|
||||
)
|
||||
self.assertEqual(ex.exception, "Error: 'nstep' keyword not defined appropriately in config file")
|
||||
self.assertEqual(
|
||||
ex.exception,
|
||||
"Error: 'nstep' keyword not defined appropriately in config file",
|
||||
)
|
||||
|
||||
def test_from_dict(self):
|
||||
dice_dto = DiceConfig.from_dict({
|
||||
'ljname': 'test',
|
||||
'outname': 'test',
|
||||
'dens': 1.0,
|
||||
'nmol': [1],
|
||||
'nstep': [1, 1],
|
||||
})
|
||||
dice_dto = DiceConfig.from_dict(
|
||||
{
|
||||
"ljname": "test",
|
||||
"outname": "test",
|
||||
"dens": 1.0,
|
||||
"nmol": [1],
|
||||
"nstep": [1, 1],
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIsInstance(dice_dto, DiceConfig)
|
||||
self.assertIsInstance(dice_dto, DiceConfig)
|
||||
|
||||
@@ -6,9 +6,9 @@ import unittest
|
||||
class TestGaussianDTO(unittest.TestCase):
|
||||
def test_class_instantiation(self):
|
||||
gaussian_dto = GaussianDTO(
|
||||
level='test',
|
||||
qmprog='g16',
|
||||
keywords='test',
|
||||
level="test",
|
||||
qmprog="g16",
|
||||
keywords="test",
|
||||
)
|
||||
|
||||
self.assertIsInstance(gaussian_dto, GaussianDTO)
|
||||
@@ -16,30 +16,30 @@ class TestGaussianDTO(unittest.TestCase):
|
||||
def test_is_valid_qmprog(self):
|
||||
with self.assertRaises(ValueError):
|
||||
gaussian_dto = GaussianDTO(
|
||||
level='test',
|
||||
qmprog='test',
|
||||
keywords='test',
|
||||
level="test",
|
||||
qmprog="test",
|
||||
keywords="test",
|
||||
)
|
||||
|
||||
def test_is_valid_level(self):
|
||||
with self.assertRaises(ValueError):
|
||||
gaussian_dto = GaussianDTO(
|
||||
level=None,
|
||||
qmprog='g16',
|
||||
keywords='test',
|
||||
qmprog="g16",
|
||||
keywords="test",
|
||||
)
|
||||
|
||||
def test_from_dict(self):
|
||||
gaussian_dto = GaussianDTO.from_dict(
|
||||
{
|
||||
'level': 'test',
|
||||
'qmprog': 'g16',
|
||||
'keywords': 'test',
|
||||
"level": "test",
|
||||
"qmprog": "g16",
|
||||
"keywords": "test",
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIsInstance(gaussian_dto, GaussianDTO)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
from diceplayer.shared.config.dice_config import DiceConfig
|
||||
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
|
||||
|
||||
|
||||
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],
|
||||
"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",
|
||||
},
|
||||
'gaussian': {
|
||||
'level': 'test',
|
||||
'qmprog': 'g16',
|
||||
'keywords': 'test',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestPlayerDTO(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.dice_dto = DiceConfig(
|
||||
ljname='test',
|
||||
outname='test',
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
self.gaussian_dto = GaussianDTO(
|
||||
level='test',
|
||||
qmprog='g16',
|
||||
keywords='test',
|
||||
level="test",
|
||||
qmprog="g16",
|
||||
keywords="test",
|
||||
)
|
||||
|
||||
def test_class_instantiation(self):
|
||||
@@ -50,7 +50,7 @@ class TestPlayerDTO(unittest.TestCase):
|
||||
nprocs=4,
|
||||
ncores=4,
|
||||
dice=self.dice_dto,
|
||||
gaussian=self.gaussian_dto
|
||||
gaussian=self.gaussian_dto,
|
||||
)
|
||||
|
||||
self.assertIsInstance(player_dto, PlayerConfig)
|
||||
@@ -66,20 +66,18 @@ class TestPlayerDTO(unittest.TestCase):
|
||||
ncores=4,
|
||||
altsteps=100,
|
||||
dice=self.dice_dto,
|
||||
gaussian=self.gaussian_dto
|
||||
gaussian=self.gaussian_dto,
|
||||
)
|
||||
|
||||
self.assertEqual(player_dto.altsteps, 20000)
|
||||
|
||||
def test_from_dict(self):
|
||||
player_dto = PlayerConfig.from_dict(
|
||||
get_config_dict()
|
||||
)
|
||||
player_dto = PlayerConfig.from_dict(get_config_dict())
|
||||
|
||||
self.assertIsInstance(player_dto, PlayerConfig)
|
||||
self.assertIsInstance(player_dto.dice, DiceConfig)
|
||||
self.assertIsInstance(player_dto.gaussian, GaussianDTO)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user