Skip to content

Commit

Permalink
sys test assertion and formatting modify singlept site neon
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaganKing committed Oct 26, 2023
1 parent 85610b5 commit 5714ffb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
19 changes: 6 additions & 13 deletions python/ctsm/test/test_sys_run_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import glob
import os
import re

Expand Down Expand Up @@ -60,26 +61,18 @@ def test_one_site(self):
# run the run_neon tool
# sys.argv = ["run_neon", "--neon_sites 'ABBY'"]
# sys.argv = ["--neon_sites", ["ABBY"]]

sys.argv = ["--neon-sites 'ABBY'"]
print("sys.argv:")
print(sys.argv)
valid_neon_sites = ["ABBY", "OSBS", "BART"] # ["all"]
parser = get_parser(sys.argv, "description_for_parser", valid_neon_sites)
print("parser:")
print(parser)
main("")

# this seems to run OSBS (default site, instead of ABBY),
# but does create files! It takes a while though, should we do setup-only?
# Could assert that dir is created with files; we should also move this into a tempdir?

# the critical piece of this test is that the above command
# doesn't generate errors; however, we also do some assertions below

# fsurdat_in_data = xr.open_dataset(self._fsurdat_in)
# fsurdat_out_data = xr.open_dataset(self._fsurdat_out)
# assert that fsurdat_out equals fsurdat_in
# self.assertTrue(fsurdat_out_data.equals(fsurdat_in_data))
# Could assert that dir is created with files
#we should also move this into a tempdir and delete files after running (and cancel queue?)

self.assertTrue("OSBS" in glob.glob("*"))

if __name__ == "__main__":
unit_testing.setup_for_tests()
Expand Down
9 changes: 6 additions & 3 deletions python/ctsm/test/test_unit_modify_singlept_site_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def test_find_soil_structure(self):
Test to ensure that correct attributes are found for find_soil_structure.
soil_texture_raw_data_file_name should be found, and test should go through sysexit.
"""
surf_file = (
os.path.join(path_to_ctsm_root(), "python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206.nc")
surf_file = os.path.join(
path_to_ctsm_root(),
"python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206.nc",
)
f1 = xr.open_dataset(surf_file)
self.assertEqual(
Expand All @@ -101,7 +102,9 @@ def test_update_metadata(self):
surf_file = "surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206.nc"
neon_file = "dummy_neon_file.nc"
zb_flag = True
f1 = xr.open_dataset(os.path.join(path_to_ctsm_root(), "python/ctsm/test/testinputs/") + surf_file)
f1 = xr.open_dataset(
os.path.join(path_to_ctsm_root(), "python/ctsm/test/testinputs/") + surf_file
)
f2 = update_metadata(f1, surf_file, neon_file, zb_flag)
today = date.today()
today_string = today.strftime("%Y-%m-%d")
Expand Down

0 comments on commit 5714ffb

Please sign in to comment.