2015-08-10 11:32:08 +02:00
|
|
|
r"""
|
|
|
|
Tests of 'parse_parameter_set()' defined in ConfigParameters class
|
|
|
|
"""
|
2015-10-16 11:16:48 +02:00
|
|
|
import os
|
2020-08-03 12:17:16 +02:00
|
|
|
import rpath
|
2015-10-16 11:16:48 +02:00
|
|
|
_rpath = os.path.dirname(rpath.__file__) + '/'
|
|
|
|
|
2020-08-03 12:17:16 +02:00
|
|
|
import arraytest
|
2015-08-10 11:32:08 +02:00
|
|
|
import numpy as np
|
2018-09-06 13:48:24 +02:00
|
|
|
from triqs_dft_tools.converters.plovasp.inpconf import ConfigParameters
|
2015-08-10 11:32:08 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TestParseParameterSet
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
class TestParseParameterSet(arraytest.ArrayTestCase):
|
|
|
|
"""
|
|
|
|
Function:
|
|
|
|
|
|
|
|
def parse_parameter_set(self, section, param_set, excpetion=False)
|
|
|
|
|
|
|
|
Scenarios:
|
|
|
|
|
|
|
|
- **if** config-file section [Shell 1] contains 'LSHELL = 2' **and**
|
|
|
|
'lshell' and 'ions' are in `param_set` **return** a dictionary {'lshell': 2}
|
|
|
|
|
|
|
|
- **if** config-file section [Shell 1] contains 'LSHELL = 2' **and**
|
|
|
|
'lshell' and 'ions' are in `param_set` and
|
|
|
|
exception=True **raise** Exception
|
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# Dummy ConfigParameters object
|
2015-10-16 11:16:48 +02:00
|
|
|
self.cpars = ConfigParameters(_rpath + 'test1.cfg')
|
2015-08-10 11:32:08 +02:00
|
|
|
|
|
|
|
# Scenario 1
|
|
|
|
def test_sh_required(self):
|
|
|
|
param_set = self.cpars.sh_required # contains 'lshell' and 'ions'
|
|
|
|
res = self.cpars.parse_parameter_set('Shell 1', param_set)
|
|
|
|
expected = {'lshell': 2}
|
|
|
|
self.assertDictEqual(res, expected)
|
|
|
|
|
|
|
|
# Scenario 2
|
|
|
|
def test_sh_required_exception(self):
|
|
|
|
section = 'Shell 1'
|
|
|
|
param_set = self.cpars.sh_required # contains 'lshell' and 'ions'
|
|
|
|
err_mess = "Required parameter" # .* in section [%s]"%(section)
|
2020-04-08 21:35:59 +02:00
|
|
|
with self.assertRaisesRegex(Exception, err_mess):
|
2015-08-10 11:32:08 +02:00
|
|
|
self.cpars.parse_parameter_set(section, param_set, exception=True)
|
2020-06-10 17:45:53 +02:00
|
|
|
|