def test_invalid_method(self): """Test attempt to write with invalid method.""" method = 'unknown_file_type' msg = 'Unknown method ".*" passed to WriteOutput.' with self.assertRaisesRegex(AttributeError, msg): Plugin(method, self.data_directory).process(self.cube)
def test_invalid_output_path(self): """Test attempt to write to unwritable location.""" method = 'as_netcdf' msg = 'Permission denied' with self.assertRaisesRegexp(IOError, msg): Plugin(method, '/').process(self.cube)
def test_write_netcdf(self): """Test writing of iris.cube.Cube to netcdf file.""" method = 'as_netcdf' Plugin(method, self.data_directory).process(self.cube) result = load_cube(os.path.join(self.data_directory, 'test_data.nc')) self.assertIsInstance(result, Cube) self.assertEqual(result.name(), 'test_data') self.assertEqual(result.data.shape, (20, 20))