Index: trunk/tests/test_data_processing.py =================================================================== diff -u -r82 -r83 --- trunk/tests/test_data_processing.py (.../test_data_processing.py) (revision 82) +++ trunk/tests/test_data_processing.py (.../test_data_processing.py) (revision 83) @@ -403,19 +403,21 @@ @pytest.mark.unittest def test_given_all_args_does_not_raise(self): # 1. Given - expected_message = om.error_all_arguments_required - resampled_data = None dataset = xr.DataArray( np.sin(0.3 * np.arange(20).reshape(5, 4)), [ (OutputData.var_lon_key, np.arange(5)), (OutputData.var_lat_key, [0.1, 0.2, 0.3, 0.4])]) + dataset.attrs['cdm_data_type'] = OutputData.var_gridded resample_latitude = xr.DataArray( [0, 2, 4], dims=OutputData.var_lat_key) resample_longitude = xr.DataArray( [0, 2], dims=OutputData.var_lon_key) + expected_shape = (2, 3) + resampled_data = None + # 2. When try: resampled_data = DataProcessing.spatial_resampling_grid( @@ -429,10 +431,43 @@ ) # 3. Then - assert not resampled_data - assert str(e_info.value) == expected_message + assert resampled_data is not None + assert resampled_data.shape == (2, 3) + @pytest.mark.systemtest + def test_given_test_file_then_does_resampling(self): + # 1. Given + dataset = get_gridded_xarray_from_file() + assert dataset['SWH'] is not None + ini_t, ini_lat, ini_lon = dataset['SWH'].shape + + resample_latitude = xr.DataArray( + [0, 2, 4], + dims=OutputData.var_lat_key) + resample_longitude = xr.DataArray( + [0, 2], + dims=OutputData.var_lon_key) + expected_output_shape = (ini_t, 3, 2) + # 2. When + try: + resampled_data = DataProcessing.spatial_resampling_grid( + dataset=dataset, + resample_latitude=resample_latitude, + resample_longitude=resample_longitude) + except Exception as e_info: + pytest.fail( + 'Exception thrown, but not expected: ' + + '{}'.format(str(e_info)) + ) + + # 3. Then + assert resampled_data is not None + assert resampled_data['SWH'] is not None + assert resampled_data['SWH'].shape == expected_output_shape, '' + \ + 'The resampled lat/lon for swh does not match expected.' + + class Test_SpatialGradientsCalculation: @pytest.mark.unittest