Skip to content

Commit

Permalink
Added tests for generating the namelists
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared committed Mar 6, 2018
1 parent b01ad0b commit 7a5af23
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)

0 comments on commit 7a5af23

Please sign in to comment.