def test_grib_unknown(self): sections = [{'editionNumber': 0}] message = self._make_test_message(sections) mfunc = 'iris_grib.GribMessage.messages_from_filename' emsg = 'GRIB edition 0 is not supported' with mock.patch(mfunc, return_value=[message]): with self.assertRaisesRegex(TranslationError, emsg): next(_load_generate(self.fname))
def test_grib2(self): sections = [{'editionNumber': 2}] message = self._make_test_message(sections) mfunc = 'iris_grib.GribMessage.messages_from_filename' with mock.patch(mfunc, return_value=[message]) as mock_func: field = next(_load_generate(self.fname)) mock_func.assert_called_once_with(self.fname) self.assertEqual(field, message)
def test_grib_unknown(self): sections = [{'editionNumber': 0}] message = self._make_test_message(sections) mfunc = 'iris_grib.GribMessage.messages_from_filename' emsg = 'GRIB edition 0 is not supported' with mock.patch(mfunc, return_value=[message]): with self.assertRaisesRegexp(TranslationError, emsg): next(_load_generate(self.fname))
def test_grib1(self): sections = [{'editionNumber': 1}] message = self._make_test_message(sections) mfunc = 'iris_grib.GribMessage.messages_from_filename' mclass = 'iris_grib.GribWrapper' with mock.patch(mfunc, return_value=[message]) as mock_func: with mock.patch(mclass, spec=GribWrapper) as mock_wrapper: field = next(_load_generate(self.fname)) mock_func.assert_called_once_with(self.fname) self.assertIsInstance(field, GribWrapper) mock_wrapper.assert_called_once_with(self.message_id, grib_fh=self.grib_fh)
def test_reduced_data(self): filename = tests.get_data_path(('GRIB', 'reduced', 'reduced_ll.grib1')) messages = list(_load_generate(filename)) self.assertTrue(is_lazy_data(messages[0]._data))
def test_regular_data(self): filename = tests.get_data_path( ('GRIB', 'gaussian', 'regular_gg.grib1')) messages = list(_load_generate(filename)) self.assertTrue(is_lazy_data(messages[0]._data))
def test_regular_data(self): filename = tests.get_data_path(('GRIB', 'gaussian', 'regular_gg.grib1')) messages = list(_load_generate(filename)) self.assertTrue(is_lazy_data(messages[0]._data))