示例#1
0
 def _check_fails_in_metadata(self, automatic_fixes=False, frequency=None):
     checker = CMORCheck(self.cube,
                         self.var_info,
                         automatic_fixes=automatic_fixes,
                         frequency=frequency)
     with self.assertRaises(CMORCheckError):
         checker.check_metadata()
示例#2
0
 def test_warning_fail_on_error(self):
     """Test report warning function with fail_on_error."""
     checker = CMORCheck(self.cube, self.var_info, fail_on_error=True)
     with self.assertLogs(level='WARNING') as cm:
         checker.report_warning('New error: {}', 'something failed')
         self.assertEqual(cm.output, [
             'WARNING:esmvalcore.cmor.check:New error: something failed',
         ])
示例#3
0
 def _check_warnings_on_metadata(self, automatic_fixes=False,
                                 check_level=CheckLevels.DEFAULT):
     checker = CMORCheck(
         self.cube, self.var_info, automatic_fixes=automatic_fixes,
         check_level=check_level
     )
     checker.check_metadata()
     self.assertTrue(checker.has_warnings())
示例#4
0
 def test_warning_fail_on_error(self):
     """Test report warning function with fail_on_error"""
     checker = CMORCheck(self.cube, self.var_info, fail_on_error=True)
     stdout = sys.stdout
     sys.stdout = StringIO()
     checker.report_warning('New error: {}', 'something failed')
     output = sys.stdout.getvalue().strip()
     sys.stdout = stdout
     self.assertEqual(output, 'WARNING: New error: something failed')
示例#5
0
 def _check_fails_in_metadata(self, automatic_fixes=False, frequency=None,
                              check_level=CheckLevels.DEFAULT):
     checker = CMORCheck(
         self.cube,
         self.var_info,
         automatic_fixes=automatic_fixes,
         frequency=frequency,
         check_level=check_level)
     with self.assertRaises(CMORCheckError):
         checker.check_metadata()
示例#6
0
    def test_non_requested(self):
        """
        Warning if requested values are not present.

        Check issue a warning if a values requested
        for a coordinate are not correct in the metadata step
        """
        coord = self.cube.coord('air_pressure')
        values = np.linspace(0, 40, len(coord.points))
        self._update_coordinate_values(self.cube, coord, values)
        checker = CMORCheck(self.cube, self.var_info)
        checker.check_metadata()
        self.assertTrue(checker.has_warnings())
示例#7
0
 def checker(cube):
     return CMORCheck(
         cube,
         self.var_info,
         automatic_fixes=automatic_fixes,
         frequency=frequency,
         check_level=check_level)
示例#8
0
 def test_fail_on_error(self):
     """Test exception is raised if fail_on_error is activated."""
     checker = CMORCheck(self.cube, self.var_info, fail_on_error=True)
     with self.assertRaises(CMORCheckError):
         checker.report_critical('New error: {}', 'something failed')
示例#9
0
 def _check_warnings_on_data(self):
     checker = CMORCheck(self.cube, self.var_info)
     checker.check_metadata()
     checker.check_data()
     self.assertTrue(checker.has_warnings())
示例#10
0
 def _check_fails_on_data(self):
     checker = CMORCheck(self.cube, self.var_info)
     checker.check_metadata()
     with self.assertRaises(CMORCheckError):
         checker.check_data()
示例#11
0
 def test_report_error(self):
     """Test report error function."""
     checker = CMORCheck(self.cube, self.var_info)
     self.assertFalse(checker.has_errors())
     checker.report_critical('New error: {}', 'something failed')
     self.assertTrue(checker.has_errors())
示例#12
0
 def _check_debug_messages_on_metadata(self, automatic_fixes=False):
     checker = CMORCheck(self.cube,
                         self.var_info,
                         automatic_fixes=automatic_fixes)
     checker.check_metadata()
     self.assertTrue(checker.has_debug_messages())
示例#13
0
 def test_report_debug_message(self):
     """"Test report debug message function"""
     checker = CMORCheck(self.cube, self.var_info)
     self.assertFalse(checker.has_debug_messages())
     checker.report_debug_message('New debug message')
     self.assertTrue(checker.has_debug_messages())
示例#14
0
 def test_report_warning(self):
     """Test report warning function"""
     checker = CMORCheck(self.cube, self.var_info)
     self.assertFalse(checker.has_errors())
     checker.report_warning('New error: {}', 'something failed')
     self.assertTrue(checker.has_warnings())
示例#15
0
 def _check_debug_messages_on_metadata(self):
     checker = CMORCheck(self.cube, self.var_info)
     checker.check_metadata()
     self.assertTrue(checker.has_debug_messages())