3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-08 15:13:47 +01:00
dft_tools/python/converters/vasp/test/inpconf/test_parameter_set.py
Oleg E. Peil 9d4fb22572 Rearranged test cases for 'inpconf.py'.
A single-file test suite for 'inpconf.py' is split into several files,
each containing a separate TestCase class. In addition, all test cases
are derived from class ArrayTestCase (in turn derived from TestCase)
which contains a numpy-array equality method.
2015-10-11 13:55:04 +02:00

49 lines
1.6 KiB
Python

r"""
Tests of 'parse_parameter_set()' defined in ConfigParameters class
"""
import arraytest
import numpy as np
from inpconf import ConfigParameters
################################################################################
#
# 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
self.cpars = ConfigParameters('test1.cfg')
# 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)
with self.assertRaisesRegexp(Exception, err_mess):
self.cpars.parse_parameter_set(section, param_set, exception=True)