-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for generating the namelists
- Loading branch information
1 parent
b01ad0b
commit 7a5af23
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |