-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4452 from ESMCI/fix_hist_utils
Fixes hist utils Fixes regex pattern used to match history files. Only considers .nc files when copying history files for a tests COMPARE_PHASE. Adds a new optional attribute exclude_testing for comp_archive_spec which allows a components history files to be archived but excluded from the COMPARE_PHASE of tests when active. Test suite: pytest CIME/tests/test* Test baseline: n/a Test namelist changes: n/a Test status: n/a Fixes #4438 #4387 User interface changes?: N Update gh-pages html (Y/N)?: N
- Loading branch information
Showing
6 changed files
with
229 additions
and
20 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
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
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
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
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,66 @@ | ||
import io | ||
import unittest | ||
from unittest import mock | ||
|
||
from CIME.hist_utils import copy_histfiles | ||
from CIME.XML.archive import Archive | ||
|
||
|
||
class TestHistUtils(unittest.TestCase): | ||
@mock.patch("CIME.hist_utils.safe_copy") | ||
def test_copy_histfiles_exclude(self, safe_copy): | ||
case = mock.MagicMock() | ||
|
||
case.get_env.return_value.get_latest_hist_files.side_effect = [ | ||
["/tmp/testing.cpl.hi.nc"], | ||
["/tmp/testing.atm.hi.nc"], | ||
] | ||
|
||
case.get_env.return_value.exclude_testing.side_effect = [True, False] | ||
|
||
case.get_value.side_effect = [ | ||
"/tmp", # RUNDIR | ||
None, # RUN_REFCASE | ||
"testing", # CASE | ||
True, # TEST | ||
True, # TEST | ||
] | ||
|
||
case.get_compset_components.return_value = ["atm"] | ||
|
||
test_files = [ | ||
"testing.cpl.hi.nc", | ||
] | ||
|
||
with mock.patch("os.listdir", return_value=test_files): | ||
comments, num_copied = copy_histfiles(case, "base") | ||
|
||
assert num_copied == 1 | ||
|
||
@mock.patch("CIME.hist_utils.safe_copy") | ||
def test_copy_histfiles(self, safe_copy): | ||
case = mock.MagicMock() | ||
|
||
case.get_env.return_value.get_latest_hist_files.return_value = [ | ||
"/tmp/testing.cpl.hi.nc", | ||
] | ||
|
||
case.get_env.return_value.exclude_testing.return_value = False | ||
|
||
case.get_value.side_effect = [ | ||
"/tmp", # RUNDIR | ||
None, # RUN_REFCASE | ||
"testing", # CASE | ||
True, # TEST | ||
] | ||
|
||
case.get_compset_components.return_value = [] | ||
|
||
test_files = [ | ||
"testing.cpl.hi.nc", | ||
] | ||
|
||
with mock.patch("os.listdir", return_value=test_files): | ||
comments, num_copied = copy_histfiles(case, "base") | ||
|
||
assert num_copied == 1 |
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