Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop] Move all unittest tests to a common area. #728

Merged
merged 25 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
572b541
Move first unittest to shared location.
christinaholtNOAA Apr 12, 2023
a3fc81e
Adding another batch.
christinaholtNOAA Apr 12, 2023
f8b84c2
Moving another batch.
christinaholtNOAA Apr 12, 2023
9a55a1a
Moving another batch of tests.
christinaholtNOAA Apr 12, 2023
558d864
Moving the last set of tests.
christinaholtNOAA Apr 12, 2023
e5bbda3
Use tempfile package for easy cleanup
christinaholtNOAA Apr 12, 2023
28f39ee
Fix the relative paths after the test file moved.
christinaholtNOAA Apr 12, 2023
b2cb415
Missed a file.
christinaholtNOAA Apr 12, 2023
505808e
Linting and cleaning up a bit.
christinaholtNOAA Apr 12, 2023
fa7f6b2
Making the tests run.
christinaholtNOAA Apr 13, 2023
9c6bcb8
Update GitHub Actions.
christinaholtNOAA Apr 13, 2023
878f93a
Add Jenkins test to run the HPSS tests on jet/hera.
christinaholtNOAA Apr 13, 2023
4f35d17
Linting.
christinaholtNOAA Apr 13, 2023
500afce
Linting
christinaholtNOAA Apr 13, 2023
e7855b2
Adding a new github task to lint code that's already linted
christinaholtNOAA Apr 13, 2023
52b82e8
Tell the tests where the code is.
christinaholtNOAA Apr 13, 2023
73d7b00
Make pylint consistent with version on Hera.
christinaholtNOAA Apr 13, 2023
d020ff5
Addressing Jenkins test failures.
christinaholtNOAA Apr 21, 2023
744698c
Remove parallel section.
christinaholtNOAA Apr 24, 2023
cd6115f
Merge remote-tracking branch 'origin/develop' into move_unittests
christinaholtNOAA Apr 28, 2023
8971e22
Fix a wrapping issue.
christinaholtNOAA Apr 28, 2023
4850943
Update .cicd/scripts/srw_unittest.sh
christinaholtNOAA May 3, 2023
cf42842
Update .cicd/scripts/srw_unittest.sh
christinaholtNOAA May 3, 2023
f502547
Make changes to script found in debugging.
christinaholtNOAA May 3, 2023
23623c4
Change the call to unittest here.
christinaholtNOAA May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding another batch.
  • Loading branch information
christinaholtNOAA committed Apr 12, 2023
commit a3fc81e0d79e9ab3686b76a2f98722fbbe045ea9
27 changes: 27 additions & 0 deletions tests/test_python/test_check_ruc_lsm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
""" Test for the define_ruc_lsm script. """

#pylint: disable=invalid-name

import os
import unittest

from python_utils import set_env_var

from check_ruc_lsm import check_ruc_lsm

class Testing(unittest.TestCase):
""" Define the tests"""

def test_check_ruc_lsm(self):
"""" Read in a CCPP suite definition file and check that it is
using RUC LSM as part of the suite. """
test_dir = os.path.dirname(os.path.abspath(__file__))
USHdir = os.path.join(test_dir, "..", "..", "ush")
self.assertTrue(
check_ruc_lsm(
ccpp_phys_suite_fp=f"{USHdir}{os.sep}test_data{os.sep}suite_FV3_GSD_SAR.xml"
)
)

def setUp(self):
set_env_var("DEBUG", True)
File renamed without changes.
35 changes: 35 additions & 0 deletions tests/test_python/test_set_gridparams_GFDLgrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
""" Defines the tests for set_gridparams_GFDLgrid """

#pylint: disable=invalid-name

import unittest

from set_gridparams_GFDLgrid import set_gridparams_GFDLgrid

class Testing(unittest.TestCase):
""" Define the tests """

def test_set_gridparams_GFDLgrid(self):

""" Test that grid parameters are set as expected, and that a
list is returned with expected values. Some work here is needed
to understand why we have a list with these magic numbers."""
grid_params = set_gridparams_GFDLgrid(
lon_of_t6_ctr=-97.5,
lat_of_t6_ctr=38.5,
res_of_t6g=96,
stretch_factor=1.4,
refine_ratio_t6g_to_t7g=3,
istart_of_t7_on_t6g=13,
iend_of_t7_on_t6g=84,
jstart_of_t7_on_t6g=17,
jend_of_t7_on_t6g=80,
run_envir="community",
verbose=True,
nh4=4,
)

self.assertEqual(
list(grid_params.values()),
[-97.5, 38.5, 216, 192, 6, 1.4, 21, 172, 29, 164],
)
45 changes: 45 additions & 0 deletions tests/test_python/test_set_predef_grid_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
""" Defines tests for setting the predefined grid parameters. """

import os
import unittest

from set_predef_grid_params import set_predef_grid_params

class Testing(unittest.TestCase):

"Define the tests"

def test_set_predef_grid_params(self):
""" Check that the method called updates or sets specific entries
in the parameter dict."""
test_dir = os.path.dirname(os.path.abspath(__file__))
ushdir = os.path.join(test_dir, "..", "..", "ush")
fcst_config = dict(
PREDEF_GRID_NAME="RRFS_CONUS_3km",
QUILTING=False,
DT_ATMOS=36,
LAYOUT_X=18,
LAYOUT_Y=36,
BLOCKSIZE=28,
)
params_dict = set_predef_grid_params(
ushdir,
fcst_config["PREDEF_GRID_NAME"],
fcst_config["QUILTING"],
)
self.assertEqual(params_dict["GRID_GEN_METHOD"], "ESGgrid")
self.assertEqual(params_dict["ESGgrid_LON_CTR"], -97.5)
fcst_config = dict(
PREDEF_GRID_NAME="RRFS_CONUS_3km",
QUILTING=True,
DT_ATMOS=36,
LAYOUT_X=18,
LAYOUT_Y=36,
BLOCKSIZE=28,
)
params_dict = set_predef_grid_params(
ushdir,
fcst_config["PREDEF_GRID_NAME"],
fcst_config["QUILTING"],
)
self.assertEqual(params_dict["WRTCMP_nx"], 1799)
14 changes: 0 additions & 14 deletions ush/check_ruc_lsm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

import os
import unittest

from python_utils import (
set_env_var,
Expand All @@ -26,16 +25,3 @@ def check_ruc_lsm(ccpp_phys_suite_fp):
tree = load_xml_file(ccpp_phys_suite_fp)
has_ruc = has_tag_with_value(tree, "scheme", "lsm_ruc")
return has_ruc


class Testing(unittest.TestCase):
def test_check_ruc_lsm(self):
USHdir = os.path.dirname(os.path.abspath(__file__))
self.assertTrue(
check_ruc_lsm(
ccpp_phys_suite_fp=f"{USHdir}{os.sep}test_data{os.sep}suite_FV3_GSD_SAR.xml"
)
)

def setUp(self):
set_env_var("DEBUG", True)
26 changes: 0 additions & 26 deletions ush/set_gridparams_GFDLgrid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

import os
import unittest

from python_utils import (
import_vars,
Expand Down Expand Up @@ -478,28 +477,3 @@ def set_gridparams_GFDLgrid(
"JEND_OF_RGNL_DOM_WITH_WIDE_HALO_ON_T6SG": jend_of_t7_with_halo_on_t6sg,
}


class Testing(unittest.TestCase):
def test_set_gridparams_GFDLgrid(self):
grid_params = set_gridparams_GFDLgrid(
lon_of_t6_ctr=-97.5,
lat_of_t6_ctr=38.5,
res_of_t6g=96,
stretch_factor=1.4,
refine_ratio_t6g_to_t7g=3,
istart_of_t7_on_t6g=13,
iend_of_t7_on_t6g=84,
jstart_of_t7_on_t6g=17,
jend_of_t7_on_t6g=80,
run_envir="community",
verbose=True,
nh4=4,
)

self.assertEqual(
list(grid_params.values()),
[-97.5, 38.5, 216, 192, 6, 1.4, 21, 172, 29, 164],
)

def setUp(self):
pass
35 changes: 0 additions & 35 deletions ush/set_predef_grid_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

import unittest
import os
from textwrap import dedent

Expand Down Expand Up @@ -39,37 +38,3 @@ def set_predef_grid_params(USHdir, grid_name, quilting):
params_dict = flatten_dict(params_dict)

return params_dict


class Testing(unittest.TestCase):
def test_set_predef_grid_params(self):
ushdir = os.path.dirname(os.path.abspath(__file__))
fcst_config = dict(
PREDEF_GRID_NAME="RRFS_CONUS_3km",
QUILTING=False,
DT_ATMOS=36,
LAYOUT_X=18,
LAYOUT_Y=36,
BLOCKSIZE=28,
)
params_dict = set_predef_grid_params(
ushdir,
fcst_config["PREDEF_GRID_NAME"],
fcst_config["QUILTING"],
)
self.assertEqual(params_dict["GRID_GEN_METHOD"], "ESGgrid")
self.assertEqual(params_dict["ESGgrid_LON_CTR"], -97.5)
fcst_config = dict(
PREDEF_GRID_NAME="RRFS_CONUS_3km",
QUILTING=True,
DT_ATMOS=36,
LAYOUT_X=18,
LAYOUT_Y=36,
BLOCKSIZE=28,
)
params_dict = set_predef_grid_params(
ushdir,
fcst_config["PREDEF_GRID_NAME"],
fcst_config["QUILTING"],
)
self.assertEqual(params_dict["WRTCMP_nx"], 1799)