-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_process.py
37 lines (29 loc) · 1.15 KB
/
test_process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from unittest import TestCase
from wrfconf.process import create_wrf_namelist, create_wps_namelist, ordered_load
from six import StringIO
class TestWRF(TestCase):
def setUp(self):
self.cfg = ordered_load(open('examples/run.yml'))
with open('examples/namelist.input') as f:
lines = f.readlines()
self.expected = ''.join(lines)
def test_create(self):
self.assertEqual(create_wrf_namelist(self.cfg), self.expected)
def test_stream(self):
stream = StringIO()
create_wrf_namelist(self.cfg, stream)
stream.seek(0)
self.assertEqual(''.join(stream.readlines()), self.expected)
class TestWPS(TestCase):
def setUp(self):
self.cfg = ordered_load(open('examples/run.yml'))
with open('examples/namelist.wps') as f:
lines = f.readlines()
self.expected = ''.join(lines)
def test_create(self):
self.assertEqual(create_wps_namelist(self.cfg), self.expected)
def test_stream(self):
stream = StringIO()
create_wps_namelist(self.cfg, stream)
stream.seek(0)
self.assertEqual(''.join(stream.readlines()), self.expected)