setup.py moved to python/python. moved python tests to python/python. added __init__.py under python/tests. added 'test_' before all python test names. test_ prefix added to tests. setup.py and python tests moved back to python base. setuptools executes from root python. python: tests run from root python w/ setup.py. python tests: temp reduced to test_deck only. python setup.py: manually linked opmcommon. setup.py: linked ecl. setup.py linked boost_filesystem. setup.py: linked boost_regex. python all tests run. removec usr/local from setup.py ext_module. cmake make copies entire python dir to build. setup.py can execute from build. setup.py executes from build/python. python tests run under setup.py. setup.py library_dirs and include-dirs set by cmake command. removed cmake files from sunbeam. sunbeam: added code for install. setup.py: removed 'import ecl'. python/src -> python->src_sunbeam. setup.py: discontinued use of glob, all files listed instead. build-opm_module.sh: added prefix_path to opm. build-opm-module.sh: changed spell error for EXTRA_MODULE_FLAGS[opm-common]. setup.py: infer include directories from cmake target CMakeLists.txt: under python: align install statement. CMakeLists build python: removed find_package. src_sunbeam -> cxx. setup.py: test_suite as string. setup.py: tests_suite -> test_suite. setup.py: added exception if 'build_ext' not used. temporarily moved files to python/sunbeam.
74 lines
1.7 KiB
Python
74 lines
1.7 KiB
Python
import unittest
|
|
import sunbeam.deck
|
|
|
|
class TestParse(unittest.TestCase):
|
|
|
|
DECK_STRING = """
|
|
START -- 0
|
|
10 MAI 2007 /
|
|
RUNSPEC
|
|
|
|
DIMENS
|
|
2 2 1 /
|
|
GRID
|
|
DX
|
|
4*0.25 /
|
|
DY
|
|
4*0.25 /
|
|
DZ
|
|
4*0.25 /
|
|
TOPS
|
|
4*0.25 /
|
|
REGIONS
|
|
OPERNUM
|
|
3 3 1 2 /
|
|
FIPNUM
|
|
1 1 2 3 /
|
|
"""
|
|
|
|
def setUp(self):
|
|
self.deck = sunbeam.deck.parse_string(self.DECK_STRING)
|
|
|
|
def test_deck_in(self):
|
|
map(lambda kw: self.assertIn(kw, self.deck), [
|
|
'START', 'RUNSPEC', 'DIMENS',
|
|
'GRID', 'TOPS', 'REGIONS',
|
|
'OPERNUM', 'FIPNUM'
|
|
])
|
|
map(lambda kw: self.assertNotIn(kw, self.deck), [
|
|
'PPCWMAX', 'APIGROUP', 'NOWARN', 'WARN', 'TBLKFAI4', 'WINJMULT'
|
|
])
|
|
|
|
def test_deck_str(self):
|
|
self.assertEqual(
|
|
'DIMENS 2 2 1 /'.split(),
|
|
str(self.deck['DIMENS']).split()
|
|
)
|
|
self.assertEqual(
|
|
'DX 0.25 0.25 0.25 0.25 /'.split(),
|
|
str(self.deck['DX']).split()
|
|
)
|
|
self.assertEqual(
|
|
str(sunbeam.deck.parse_string('RUNSPEC\n\nDX\n4*0.5 /')).split(),
|
|
'RUNSPEC DX 0.5 0.5 0.5 0.5 /'.split()
|
|
)
|
|
|
|
def test_deck_keyword(self):
|
|
for kw in self.deck:
|
|
self.assertTrue(len(kw.name) > 0)
|
|
for rec in kw:
|
|
self.assertTrue( len(rec) > 0 )
|
|
for item in rec:
|
|
self.assertTrue(len(item) > 0)
|
|
|
|
def test_deck_FIPNUM(self):
|
|
self.assertIn('FIPNUM', self.deck)
|
|
self.assertEqual(len(self.deck['FIPNUM']), 1)
|
|
self.assertEqual(len(self.deck['FIPNUM'][0]), 1)
|
|
self.assertEqual(len(self.deck['FIPNUM'][0][0]), 4)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|
|
|