2015-08-10 11:32:08 +02:00
|
|
|
r"""
|
|
|
|
Tests of 'parse_groups()' 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
|
|
|
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TestParseGroups
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
class TestParseGroups(arraytest.ArrayTestCase):
|
|
|
|
"""
|
|
|
|
Function:
|
|
|
|
|
|
|
|
def parse_groups(self)
|
|
|
|
|
|
|
|
Scenarios:
|
|
|
|
|
|
|
|
- **if** a [Group] section does not contain all required parameters
|
|
|
|
**raise** Exception
|
|
|
|
- **if** a correct group section is defined **return** a list of dictionaries
|
|
|
|
"""
|
|
|
|
# Scenario 1
|
|
|
|
def test_gr_required(self):
|
2015-10-16 11:16:48 +02:00
|
|
|
conf_pars = ConfigParameters(_rpath + 'parse_groups_1.cfg')
|
2015-08-10 11:32:08 +02:00
|
|
|
err_mess = "Required parameter"
|
2020-04-08 21:35:59 +02:00
|
|
|
with self.assertRaisesRegex(Exception, err_mess):
|
2015-08-10 11:32:08 +02:00
|
|
|
conf_pars.parse_groups()
|
|
|
|
|
|
|
|
# Scenario 2
|
|
|
|
def test_example(self):
|
2015-10-16 11:16:48 +02:00
|
|
|
conf_pars = ConfigParameters(_rpath + 'example.cfg')
|
2015-08-10 11:32:08 +02:00
|
|
|
conf_pars.parse_groups()
|
|
|
|
res = conf_pars.groups
|
2015-11-13 13:54:26 +01:00
|
|
|
expected = [{'index': 1, 'shells': [1, 2], 'ewindow': (-7.6, 3.0),
|
2019-06-28 14:47:15 +02:00
|
|
|
'normalize': True, 'normion': True,'complement': False},
|
2015-11-13 13:54:26 +01:00
|
|
|
{'index': 2, 'shells': [3], 'ewindow': (-1.6, 2.0),
|
2019-06-28 14:47:15 +02:00
|
|
|
'normalize': True, 'normion': True,'complement': False}]
|
2020-04-08 21:35:59 +02:00
|
|
|
print(res)
|
|
|
|
print(expected)
|
2015-08-10 11:32:08 +02:00
|
|
|
self.assertListEqual(res, expected)
|
|
|
|
|
|
|
|
|
|
|
|
|