-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into jgfouca/ignore_diff…
…s_option * origin/master: Removes workflow trigger Fixes black formatting Fixes finding termination message in logs Fix test Remove unneeded test Fixes ternary condition for testing jobs Trigger testing/building workflow Fixes workflow for forked repo pr case.submit: Always try to download input data
- Loading branch information
Showing
5 changed files
with
59 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,50 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from CIME.utils import CIMEError | ||
from CIME.case.case_run import TERMINATION_TEXT | ||
from CIME.case.case_run import _post_run_check | ||
|
||
|
||
def _case_post_run_check(): | ||
case = mock.MagicMock() | ||
|
||
# RUNDIR, COMP_INTERFACE, COMP_CPL, COMP_ATM, COMP_OCN, MULTI_DRIVER | ||
case.get_value.side_effect = ("/tmp/run", "mct", "cpl", "satm", "socn", False) | ||
|
||
# COMP_CLASSES | ||
case.get_values.return_value = ("CPL", "ATM", "OCN") | ||
|
||
return case | ||
|
||
|
||
class TestCaseSubmit(unittest.TestCase): | ||
@mock.patch("os.stat") | ||
@mock.patch("os.path.isfile") | ||
def test_post_run_check(self, isfile, stat): | ||
isfile.return_value = True | ||
|
||
stat.return_value.st_size = 1024 | ||
|
||
# no exceptions means success | ||
for x in TERMINATION_TEXT: | ||
case = _case_post_run_check() | ||
|
||
with mock.patch("builtins.open", mock.mock_open(read_data=x)) as mock_file: | ||
_post_run_check(case, "1234") | ||
|
||
@mock.patch("os.stat") | ||
@mock.patch("os.path.isfile") | ||
def test_post_run_check_no_termination(self, isfile, stat): | ||
isfile.return_value = True | ||
|
||
stat.return_value.st_size = 1024 | ||
|
||
case = _case_post_run_check() | ||
|
||
with self.assertRaises(CIMEError): | ||
with mock.patch( | ||
"builtins.open", | ||
mock.mock_open(read_data="I DONT HAVE A TERMINATION MESSAGE"), | ||
) as mock_file: | ||
_post_run_check(case, "1234") |